unless can work in exactly the same way because unless is just the opposite of if: : unless « Statement « Ruby






unless can work in exactly the same way because unless is just the opposite of if:

age = 10
unless age >= 18
  puts "You're too young to use this system"
  puts "So we're going to exit your program now"
  exit
end

 








Related examples in the same category

1.Syntax of the full unless statement:
2.unless statement simply operates in the logically reverse sense from the if statement
3.To get the opposite effect of if you can use the word unless: