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
2 Respostas
+ 3
Your when should be like this:
when 0..17
to_i not to._i
extra " at end of first line.
+ 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