change the order: placing if after puts, and you can drop then and end. : if as modifier « Statement « Ruby






change the order: placing if after puts, and you can drop then and end.


x = 256
puts "x equals 256" if x == 256

 








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.If the value of age is under 18, the string is printed to the screen.