Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In addition to conditionals, loops, and iterators, Ruby supports a number of statements that alter the flow-of-control in a Ruby program. These statements are:
return
break
next
Causes a loop (or iterator) to skip the rest of the current iteration and move on to the next iteration.
redo
retry
Restarts an iterator, reevaluating the entire expression. The retry keyword can also be used in exception handling, as we’ll see later in the chapter.
throw/catch
A very general control structure that is named like and works like an exception propagation and handling mechanism. throw and catch are not Ruby’s primary exception mechanism (that would be raise and rescue, described later in this chapter). Instead, they are used as a kind of multilevel or labeled break.