Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This section documents Ruby’s simple looping statements: while, until, and for. Ruby also includes the ability to define custom looping constructs known as iterators. Iterators (see Section 5.3) are probably more commonly used than Ruby’s built-in looping statements; they are documented later in this chapter.
Ruby’s basic looping statements are while and until. They execute a chunk of code while a certain condition is true, or until the condition becomes true. For example: