Can self
ever evaluate to false or nil?
For example...
class FooBar
...
def check_this
self && check_something_else
end
end
Is the self &&
in this conditional necessary?
Yes. Remember everything in Ruby is an object so self
is falsy for false
and nil
:
nil.instance_eval { self } # => nil
false.instance_eval { self } # => false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With