Problem with gets.chomp!


#1

hi there,
I'm having a serious problem with gets.chomp. When ever I assign some code like

user_name = gets.chomp

my code doesn't work. I'm totally stuck at "thith meanth war!". Any solution?


#2

When this line runs you will need to input something at the prompt in the console.


#3

Thanks Roy for your kind reply.
There comes the problem. It does take any input. Seems like it freezes. I even tried different browsers to check if that was a problem from my browser. But no, same thing happened for all of the browsers. I guess there might be a technical problem.


#4

As of July 12, 2017, Ruby is no longer offered. Start our new course Learn Ruby below

Please post a link to the exercise you are on. Thanks.


#5

here is the link
https://www.codecademy.com/courses/learn-ruby/lessons/thith-meanth-war/exercises/getting-user-input?action=lesson_resume
thank you


#6

Didn't freeze for me.

print "Your input would be appreciated!"
user_input = gets.chomp #.downcase!
if user_input.include? "s"
  user_input.gsub!(/s/, "th")
  puts "Your string: #{user_input}"
else
  puts "Yes, there are no 's's"
end

#7

thanks a lot Roy. This time it ran correctly.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.