Code Editor
Learn
Control Flow in Ruby

Else

The partner to the if statement is the else statement. An if/else statement says to Ruby: "If this expression is true, run this code block; otherwise, run the code after the else statement." Here's an example:

if 1 > 2 print "I won't get printed because one is less than two." else print "That means I'll get printed!" end
Report a Bug
If you see a bug or any other issue with this page, please report it here.