ITP - flow control - conditional

A conditional is a fork (or many forks) in the road. Your data
approaches a conditional and the conditional then tells the data where
to go based on some defined parameters. Conditionals are formed using a
combination of if statements and comparison operators (<, >, <=, >=, ==,
!=, &&, ||). They are basic logical structures that are defined with the
reserved words if, else, elsif, and end. Note that elsif is missing an
"e". Enough talking, time to code.

Create a file called conditional.rb and type the following code into it.

puts "Put in a number"
a = gets.chomp.to_i

if a == 3
  puts "a is 3"
elsif a == 4
  puts "a is 4"
else
  puts "a is neither 3, nor 4"
end

Here we are using gets to let the user input a number, chomp gets rid of
the new line created when the user enters the data, and to_i is a method
that can be called on a string to turn it into an integer. We need to
convert the input into an integer because gets always gives us a string.