Control Flow in Ruby


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
Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.