小写和小写之间的区别!在Ruby中

前端之家收集整理的这篇文章主要介绍了小写和小写之间的区别!在Ruby中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我只是在学习 Ruby,我不太明白几种 Ruby方法之间的差异,有没有’!’最后.有什么不同?为什么我会用另外一个?

解决方法

最后有感叹号的方法通常被称为爆炸方法.爆炸方法不一定修改其接收器,并且不保证没有感叹号的方法不会.

这在this blog post年都很好解释.引用帖子:

The ! in method names that end with !
means,“This method is dangerous”—or,
more precisely,this method is the
“dangerous” version of an otherwise
equivalent method,with the same name
minus the !. “Danger” is relative; the
! doesn’t mean anything at all unless
the method name it’s in corresponds to
a similar but bang-less method name.

The ! does not mean “This method changes its receiver.” A lot of “dangerous” methods do change their receivers. But some don’t. I repeat: ! does not mean that the method changes its receiver.

原文链接:https://www.f2er.com/ruby/267021.html

猜你在找的Ruby相关文章