+ 2

Hi friends ,encountered with another problem...

this was the code- print "Enter your name:" x=gets print "welcome #{x} , Have a great day ahead" print "enter your age:" y=gets if y < 18 puts "You Are An Adult Now" else puts "You Are A Child Now" end

26th Jun 2018, 8:58 AM
Swapnil Srivastava
Swapnil Srivastava - avatar
3 Respostas
+ 8
you can't compare string to integer(gets method returns a string); it should be "y = gets.to_i" so the code works correctly.
26th Jun 2018, 9:13 AM
Lord Krishna
Lord Krishna - avatar
+ 1
The program runs nicely until line 6
26th Jun 2018, 8:58 AM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 1
if anyone figures any syntax error plz tell me
26th Jun 2018, 9:00 AM
Swapnil Srivastava
Swapnil Srivastava - avatar