From: Jacob Fugal Date: 2006-02-03T02:59:26+09:00 Subject: Re: Chomping and stomping On 2/2/06, ara.t.howard@noaa.gov wrote: > harp:~ > ruby a.rb < /dev/null > a.rb:3:in `chomper': private method `chomp' called for nil:NilClass (NoMethodError) > from a.rb:9 > > nil doesn't like that! ;-) Heh, yeah, I glossed over that too. You really need to check the result of gets before you chomp it. This is the way I'd write John's original loop (same semantics): def chomper while xx = gets xx.chomp! break if xx == 'qq' puts "hit me with a squirell!" end xx end and the way I'd write it for myself (different semantics, mostly same intent): def chomped_gets (s = gets) and s.chomp end def chomper loop do puts "hit me with a squirell!" break unless xx = chomped_gets return xx if xx == 'qq' end end Jacob Fugal