3 ms·
I think the example for that is bad, when you look at what it's trying to explain. def foo_matches? @foo == :bar end It returns true if it does, an
by FuzzyDunlop 14y ago
I think the example for that is bad, when you look at what it's trying to explain.
def foo_matches?
@foo == :bar
end
It returns true if it does, and false if it doesn't, as opposed to true or nil. Which is miles better than any of those alternatives.
It also failed to consider that the naming of the method and the usage of Ruby naming conventions is just as important as what goes on in the body.
- stephth 14y agoAgreed, this is an example where returning true or false would be more useful. I presumed the point was assuming a situation where a method returning either a value or nil would be desirable.