3 ms·
IME using any value as boolean never caused me any problem, neither in ruby nor in other languages where the same is possible. What stuff should happen when so
by riffraff 15y ago
IME using any value as boolean never caused me any problem, neither in ruby nor in other languages where the same is possible.
What stuff should happen when something is unexpectedly nil if you tested it for truth-ishnes? Once you have written
if not some_value
something with some_value
end
the only things you can do with `x` are things you can do with `false`, which are not many.
- Confusion 15y agoSee my response to necubi. The main problem is the reverse: if some_value something with some_value end where you first use nil to signal false, but later change the base case of some_value from nil to 0, nil to NullObject or nil to some other base value. Since you think of these base cases as 'nothing', you will forget to change this related conditional the first time around, because it seems it would still do the right thing.