Chapter 6. Control-flow techniques

 

In this chapter

  • Conditional execution
  • Loops and looping techniques
  • Iterators
  • Exceptions and error handling

 

As you’ve already seen in the case of method calls—where control of the program jumps from the spot where the call is made to the body of the method definition—programs don’t run in a straight line. Instead, execution order is determined by a variety of rules and programming constructs collectively referred to as control-flow techniques.

Ruby’s control-flow techniques include the following:

  • Conditional execution— Execution depends on the truth of an expression.
  • Looping— A single segment of code is executed repeatedly.
  • Iteration— A call to a method is supplemented with a segment of code that ...

Get The Well-Grounded Rubyist now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.