Home
Ruby
ActiveRecord
Array
CGI
Class
Collections
Database
Date
Design Patterns
Development
File Directory
GUI
Hash
Language Basics
Method
Network
Number
Rails
Range
Reflection
Statement
String
Threads
Time
Tk
Unit Test
Windows Platform
XML
Output based on if statement : if as modifier « Statement « Ruby
Ruby
Statement
if as modifier
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.