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
I prefer using a more cleaner approach :
val.to_i.zero?
val.to_i will return a 0 if val is a nil,
val.to_i
0
nil
after that, all we need to do is check whether the final value is a zero.