Summary
In this chapter, we learned about program flow. Program flow is a foundational concept in programming that allows programmers to change execution paths dynamically depending on any number of conditions. A core concept within program flow is understanding the Boolean data type along with its truthy operators, AND (&&
) and OR (||
).
We learned that Ruby supports different program flow options, such as if
and unless
, which are logical inverses of each other. The decision to use one or the other depends on the programmer, who should opt for readability and maintainability.
We also learned how to loop and were introduced to Ruby blocks, which are bundles of code that get executed along with each iteration of a loop. Bundling code into reusable chunks is also a foundational concept. Another way to bundle code is by using methods, which we've looked at only briefly so far. In the next chapter, we will go into greater depth about methods by learning how to define...