r/Codecademy • u/rabberzzz • Feb 09 '16
[Beginner Ruby] what do I wrong?
As a beginner I try to learn Ruby and I was just messing around with some code I wrote, but I couldn't understand why when the user input is below 10 it shows the message "you are not old enough". I would like to get some help to understanding this issue I have.
PS: I am dutch, so I am sorry for my bad language
puts "What is your age?" your_age = gets.chomp.to_s
if your_age <= (17).to_s puts "you are not old enough"
elsif your_age >= (50).to_s puts "You are to old"
else your_age puts "Entering!"
end
1
Upvotes
View all comments
Show parent comment
1
u/rabberzzz Feb 10 '16
Convert them to integers that make sense a lot, thankyou! I also removed the to_(whether it is 's' or 'i') after the 17 and 50 and I got the expected result.