From: William James Date: 2006-02-03T04:13:18+09:00 Subject: Re: Chomping and stomping William James wrote: > John Maclean wrote: > > Chaps, > > > > Here's a short script to keep requesting for input... > > > > #!/usr/bin/ruby -w > > def chomper > > xx = gets.chomp! > > until $_ == "qq" > > puts "hit me with a squirell!" > > xx = gets.chomp! > > xx > > end > > end > > > > chomper > > > > # this works but surely there must be a way to incoporate a variable > > in there? > > > > #!/usr/bin/ruby -w > > def chomper > > xx = gets.chomp! > > until xx == "qq" > > puts "hit me with a squirell!" > > xx > > end > > end > > > > #this don't work. > > > def chomper > until (xx = gets.chomp) == 'qq' > puts "hit me with a squirell!" > end > xx > end > > puts chomper def chomper puts "Hit me!" while gets and $_.chomp! != "qq" $_ if $_ end