Why it shows error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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 Answers
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