Ruby/Number/zero
Материал из Wiki.crossplatform.ru
if a value is a zero or not.
op = 0 op.zero? # => true op.nonzero? # => false
Use if statement to check zero
op = 0 if !op.zero? # not a zero? puts 12 / op else puts "Can"t divide by zero." end op = 2 if op.nonzero? # is it nonzero? puts 12 / op else puts "Can"t divide by zero." end