I am using the following code to check if a variable is not nil and not zero
if(discount != nil && discount != 0) ... end
Is the
ok, after 5 years have passed....
if discount.try :nonzero? ... end
It's important to note that try is defined in the ActiveSupport gem, so it is not available in plain ruby.
try