If the value of age is under 18, the string is printed to the screen. : if as modifier « Statement « Ruby






If the value of age is under 18, the string is printed to the screen.


age = 10
puts "You're too young to use this system" if age < 18

age = 10
if age < 18
  puts "You're too young to use this system"
end

 








Related examples in the same category

1.using if as a modifier with Boolean operator
2.Output based on if statement
3.test for equality:
4.change the order: placing if after puts, and you can drop then and end.