That article was updated in 2017 by theory.org, it does not follow good pages guide and may have outdated information.Help us to maintain it with Edit on GitHub link
String#downcase? Who calls it “downcase?” It’s called “lower case,” and the method should be called “lowercase” or “lower”. And
String#upcaseshould have been called “uppercase” or “upper”. It does not actually make Ruby suck, it’s just a matter of personal taste.
@@to access instance and class members can be unclear at a glance.
nil.to_iturns nil into 0, but 0 does not evaluate as nil.
nil.to_i.nil? #=> false
String#to_ijust ignores trailing characters, meaning:
"x".to_i == 0
begin ... rescue ... end if expr. You are guaranteed to miss the
if exprif there are a lot of lines in the code block.
unlesskeyword (acts like
if not) tends to make the code harder to comprehend instead of easier, for some people.
nilif you want to make your function “void” (a procedure). Like if you really care about that return value.
Hash) have a very big interfaces that make them hard to emulate. So don’t emulate - inherit instead.
class ThingLikeArray < Array; end
"foo" != :foo, which led to inventions like