From: Sven Schott Date: 2010-09-07T07:59:14+09:00 Subject: Re: Problem with 'chomp' --0016364ecee4a3ead1048f9f3a7c Content-Type: text/plain; charset=ISO-8859-1 Really? I'm using ruby 1.8.7 (on a mac) and the code runs fine for me. Not that I disagree with the comment though: I think the receiver should be used for clarity. btw, runs fine in irb and ruby proper. On Tue, Sep 7, 2010 at 8:27 AM, Xavier Noria wrote: > On Tue, Sep 7, 2010 at 12:11 AM, Barry O'gorman > wrote: > > > Simple program: > > > > while($_ != "q") > > puts "Running..." > > print "Enter q to quit: " > > gets > > chomp > > end > > > > However - getting the following in any progams in which I use 'chomp': > > 'undefined local variable or method 'chomp' for main: Object (NameError) > > chomp, gsub, and others can only be used without a receiver in > one-liners. They are thought for making -p loops and such short. > > In regular Ruby you normally use explicit variables (and in regular > Perl you normally also do). > > --0016364ecee4a3ead1048f9f3a7c--