unless statement simply operates in the logically reverse sense from the if statement : unless « Statement « Ruby





unless statement simply operates in the logically reverse sense from the if statement



temperature = 76
    
unless temperature < 65 || temperature > 85
  puts "Picnic time!"
else
  puts "Sorry, no picnic today."
end

 










Related examples in the same category

1.Syntax of the full unless statement:
2.To get the opposite effect of if you can use the word unless:
3.unless can work in exactly the same way because unless is just the opposite of if: