Unless

puts "x" unless 1==2
#=> x

unless 1==2
  puts "x"
end
#=> x
# unless one equal to two is TRUE, otherwise output x

# same as

if not 1==2
  puts "x"
end
# => x
# if one equal to two is NOT TRUE, then output x

puts "y" unless 1==1
#=> nil

unless 1==1
  puts "x"
end
#=> nil
# unless one equal to one is TRUE, otherwise output x

If vs Unless

print 1 if true
#=> 1
print 1 unless false
#=> 1

Reference

results matching ""

    No results matching ""