How to check if a variable is not nil and not zero in Ruby

1 Answer

0 votes
val = 32;

unless val.nil? || val == 0
    print "not nil and not zero";
end


 
# run:
# 
# not nil and not zero
#

 



answered Jun 6, 2024 by avibootz

Related questions

1 answer 292 views
1 answer 193 views
1 answer 299 views
1 answer 164 views
1 answer 245 views
1 answer 223 views
223 views asked Dec 20, 2020 by avibootz
...