Ruby Flow Control
One of the most powerful features of Ruby (and every other programming or scripting language for that matter) is the ability to build intelligence and logic into code. This is achieved through the use of control structures which decide what code is executed based on logical expressions.
In this chapter of Ruby Essentials we will look at how such control structures are built.
The Ruby if Statement
The if statement is the most basic of the Ruby control structures. if statements simply specify a section of Ruby script to be executed when a specified criteria is met. The syntax for an if statement is as follows:
if expression then
ruby code
end