In Ruby, upcase! and downcase! don't function similarly to upcase and downcase in case the string already contains all upper case or lower case characters. This post shows what the gotcha is.
on the second part of the example, did he mean for that upcase to be the bang upcase? If not, the example really doesn't make any sense.
Otherwise, this article is pretty much common sense... bang operators act on the object in-place.
Comments
daniel replied ago:
I think there are some typos in the article, but it's interesting none-the-less.
Honestly, I don't expect *anything* to be returned from the bang methods.
cosmina replied ago:
We also learn that some people don't read the docs ;)
jmcantrell replied ago:
on the second part of the example, did he mean for that upcase to be the bang upcase? If not, the example really doesn't make any sense.
Otherwise, this article is pretty much common sense... bang operators act on the object in-place.
bmorampudi replied ago:
daniel, jmcantrell
I have fixed the typos. The "upcase" method in the second instance indeed should be "upcase!"
Thanks.
Voters For This Link (6)
Voters Against This Link (6)