I frequently find myself doing this:
!(val).nil?
My code would be prettier if there was a method like
val.exists?
Is there something like that?
you can use the unless
statement, eg,
do_something unless val.nil?
which is probably pretty close to the ideal way to phrase it: if you had a non_nil?
method you'd have a negated statement instead of a positive statement like this one.
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