In the last exercise you worked out some
if-statement and then tried to guess what they are and how they work. Before you learn more I’ll explain what everything is by answering the questions you had from Study Drills. You did the Study Drills, right?
1. What do you think the
if does to the code under it? An
if-statement creates what is called a “branch” in the code. It’s kind of like those choose your own adventure books where you are asked to turn to one page if you make one choice, and another if you go a different direction. The
if-statement tells your script, “If this Boolean expression is true, then run the code under it, otherwise skip it.”
2. Why does the code under the
if need to be indented two spaces? In Ruby ...