From: Peter Vanderhaden Date: 2007-11-24T01:48:28+09:00 Subject: Re: chomp - works in irb, not in program Douglas: I forgot to mention that the puts command outputs the prompt to the screen, but the program never pauses to give the user a chance to enter anything for an answer. I'm assuming that's why the .chomp part doesn't work. The first thing I need to do is figure out why gets isn't causing the program to pause to accept the user input. Thanks, PV Peter Vanderhaden wrote: > Douglas, > Here's the method I'm using: > > def checkChange > puts "Do you want to change something else (y/N): " > changeIt = gets.chomp > if changeIt =~ /^[yY]/ > puts "Enter string to change: " > before = gets.chomp > puts "Enter new string: " > after = gets.chomp > puts "Global change? (N/y): " > global = gets.chomp > end > end # End checkChange method. > > > > > Douglas Greenshields wrote: >> How are you using it in the program? Are you using gets.chomp? Can you >> show a code sample? >> >> >> Peter Vanderhaden wrote: >>> When I try to use chomp to get user input, I get this error: >>> >>> private method `chomp' called for nil:NilClass (NoMethodError) >>> >>> from d:/scripts/ruby/fix1.rb:82:in `run' >>> from d:/scripts/ruby/fix1.rb:128 >>> >>> When I use it in irb, however it works. Anyone have any ideas what I >>> might be missing here? >>> Thanks.... -- Posted via http://www.ruby-forum.com/.