0

puts "Enter your age"" age=gets.to._i case age when age<18 puts "small baby" when age>=18 puts "big guy" end..

is a ruby code to get age from user n say if one is young or old... has an error need help

16th Sep 2018, 9:52 PM
Lord Mystic
Lord Mystic - avatar
2 Respuestas
+ 3
Your when should be like this: when 0..17 to_i not to._i extra " at end of first line.
16th Sep 2018, 11:01 PM
John Wells
John Wells - avatar
+ 1
thanks John Wells it now works fine.... puts "Enter your age" age=gets.to_i case age when 0..14 puts "Child" when 15..24 puts "Youth" when 25..64 puts "Adult" else puts "Senior" end
17th Sep 2018, 3:38 AM
Lord Mystic
Lord Mystic - avatar