O'Reilly logo

The Well-Grounded Rubyist by David A. Black

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required