Exercise 29: What If
Here is the next script of Ruby you will enter, which introduces you to
if-statement. Type this in, make it run exactly right, and then
we'll try see if your practice has paid off.
What You Should See
$ ruby ex29.rb Too many cats! The world is doomed! The world is dry! People are greater than or equal to dogs. People are less than or equal to dogs. People are dogs. $
In this extra credit, try to guess what you think the
is and what it does. Try to answer these questions in your own words
before moving onto the next exercise:
- What do you think the
ifdoes to the code under it?
- Can you put other boolean expressions from Ex. 27 in the
if-statement? Try it.
- What happens if you change the initial variables for people, cats, and dogs?