- 1
Why these codes do not work?
age = 18 user = gets.chomp case user when user >= age puts "welcome" when user <= age puts " leave" end
4 ответов
+ 15
Because user input is a string and age is an integer. You're trying to compare different data types.
+ 14
Try converting the user input to an integer using the gets.to_i method
+ 13
This works:
age = 18
user = gets.to_i
if user >= age
puts "welcome"
else
puts "leave"
end
0
what should it look like then?...i changed the value of varisble age to a string by putting double quotes...now when i run and enter any number, it gives no output