From: William James Date: 2006-02-03T02:28:19+09:00 Subject: Re: Chomping and stomping 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