Flow of Execution
Learn about the flow in which Ruby runs our code.
Feel free to skip this chapter if you understand Ruby’s program flow, defining and calling a method, returning from it, perhaps calling another method, and so on. We’ve discussed this before. Because this is a potentially confusing topic, we’ll go over it again.
Note: It’s easy for programmers to forget to explain to beginners how Ruby flows through a program and in what exact order. This is called the flow of execution, or control flow.
When we execute a Ruby file (with the ruby runtime
), it reads the Ruby code and executes it line by line, from top to bottom.
Example
Let’s look at our example from before, and how ...