From: William James Date: 2006-02-03T05:08:18+09:00 Subject: Re: Chomping and stomping Jacob Fugal wrote: > On 2/2/06, William James wrote: > > def chomper > > puts "Hit me!" while gets and $_.chomp! != "qq" > > $_ if $_ > > end > > This will always loop until EOF and then return nil. $_.chomp! (as > opposed to $_.chomp) returns nil, and nil != "qq". > It works under ruby 1.8.2 (2004-05-19) [i386-mswin32]. Did you test it? The code you posted earlier doesn't work: #!/usr/bin/ruby -w def chomper xx = gets.chomp until xx == "qq" puts "hit me with a squirell!" xx end end puts chomper Always test the code that you post, please. > Jacob Fugal > > PS. And let's not golf with this please... If you don't like golf, why watch it? def chomper puts "Hit me!" while gets.chomp! != "qq" $_ end