+ 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
9 Respostas
+ 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.
+ 11
You are welcome
+ 9
Did you define what chomp is?
+ 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?
+ 2
Thank so much! :)
+ 1
To J.G.-I thought I didn't have to since the command itself is gets.chomp
+ 1
To Agus Mei-Yes please.
+ 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?