There was an exercise that covered gets.chomp but I never thought about it returning a string. Then I found this documentation...
I was assuming that it would take the user input as is but the above link states...
- chomp is a string method (String#chomp).
- gets returns (gives you back) a string.
puts "You enter a dark room with two doors. Do you go through door #1 or door #2?"
print "> "
door = $stdin.gets.chomp
if door == "1"
puts "There's a giant bear here eating cheese cake. What do you do?"
end
...to...
puts "You enter a dark room with two doors. Do you go through door #1 or door #2?"
print "> "
door = $stdin.gets.chomp.to_i
if door == 1
puts "There's a giant bear here eating cheese cake. What do you do?"
end
..it worked as expected.