0

Why it shows error

puts "Put your mom\'s age" x = gets if x>18 puts "Your mom good :) " else puts "your mom gae" end #why error

27th Oct 2020, 3:27 PM
Bad Boy BB
Bad Boy BB - avatar
3 Antworten
0
Try doing x = gets.chomp.to_i
30th Oct 2020, 11:32 AM
MatanzaBC
MatanzaBC - avatar
0
If you put "Put your mom's age" it will not work as it will be picked up by Ruby as'Put your mom' instead of 'Put your mom\'s age'
30th Oct 2020, 11:35 AM
MatanzaBC
MatanzaBC - avatar
0
In the 'x = gets.chomp.to_i' the 'to_i' asigns the input to a variable
30th Oct 2020, 11:51 AM
MatanzaBC
MatanzaBC - avatar