To get the opposite effect of if you can use the word unless: : unless « Statement « Ruby






To get the opposite effect of if you can use the word unless:

age = 24
puts "You're NOT a teenager" unless age > 12 && age < 20

 








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.unless can work in exactly the same way because unless is just the opposite of if: