Why does it keep saying error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why does it keep saying error?

..\Playground\:6:in `<main>': undefined method `chomp' for nil:NilClass (NoMethodError) This keeps popping up after a line of code that says "answer = gets.chomp" and I don't know why. Here's the code up until the point that it tells me error: puts "Hello World" puts "How\'re you feeling?" feeling = gets.chomp puts "You\'re feeling #{feeling}. I hope you have a good day." puts "Do you like comics? \n yes or no" answer =gets.chomp

29th Apr 2017, 1:28 AM
corgi
corgi - avatar
9 Answers
+ 12
it is the limitation of code playground. i have the same problem when my code cashier need many input. work fine on laptop but always error on code playground. So thats it. offline and online compiler / intepreter work differently.
29th Apr 2017, 5:23 PM
Agus Mei
Agus Mei - avatar
+ 11
You are welcome
29th Apr 2017, 5:25 PM
Agus Mei
Agus Mei - avatar
29th Apr 2017, 5:14 PM
Agus Mei
Agus Mei - avatar
+ 9
Did you define what chomp is?
29th Apr 2017, 2:21 AM
J.G.
J.G. - avatar
+ 7
puts "Hello World" puts "How\'re you feeling?" feeling = gets.chomp puts "You\'re feeling #{feeling}. I hope you have a good day." puts "Do you like comics? \n yes or no" answer =gets.chomp puts answer i type that code and run it for the input i type happy #press enter yes #work fine, so what the problem? do you want me to give link to the code?
29th Apr 2017, 4:09 AM
Agus Mei
Agus Mei - avatar
+ 2
Thank so much! :)
29th Apr 2017, 5:25 PM
corgi
corgi - avatar
+ 1
To J.G.-I thought I didn't have to since the command itself is gets.chomp
29th Apr 2017, 2:30 AM
corgi
corgi - avatar
+ 1
To Agus Mei-Yes please.
29th Apr 2017, 5:08 PM
corgi
corgi - avatar
+ 1
Thank you so much. I must've been putting the input wrong since I only put 1 at a time. How can I make it so that you don't have to input both answers at the same time?
29th Apr 2017, 5:16 PM
corgi
corgi - avatar