Apr 13
Control structures
Control structures are blocks of code that result in either a true or false and are more commonly called loops. Loops are dependent on the satisfaction of certain conditions like in the sample program below that uses the “if..else control(loop):
if condition1 (if condition 1 is true)
instruction 1
instruction 2
.
.
instructionX
else (if condition 1 is false)
instruction 3
instruction 4
.
.
instructionX
end
As you can see, the simplicity of Ruby has it working without the need for the curly braces as with C++. Ruby simply uses the “end” keyword to signify the end of the “if..else” control structure. Another way of doing the same thing but with more conditional procesing is with the the “if..elseif..else” control structure. Syntax is shown in the following post.
Comments are off for this post
