|
|
|
|
|
by necubi
5332 days ago
|
|
Such code is everywhere in the Ruby community and explicitly endorsed by many. I have never seen code like your second example in the wild, and it's far more complicated than the idiomatic way of writing it: if some_value
do_something
end
It's a core expectation of the language that !!nil_thing == false, so why violate it? |
|
In some ways, the reverse is even worse: when you write
and you change some_value from nil to some sensible default like '', you will forget to update this clause and you will not understand why the code is being executed. If you use you don't have that problem, because the nil-test sticks out like a sore thumb.