Output based on if statement : if as modifier « Statement « Ruby






Output based on if statement


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

 








Related examples in the same category

1.using if as a modifier with Boolean operator
2.test for equality:
3.If the value of age is under 18, the string is printed to the screen.
4.change the order: placing if after puts, and you can drop then and end.