From: ara.t.howard@... Date: 2006-02-03T02:38:27+09:00 Subject: Re: Chomping and stomping On Fri, 3 Feb 2006, 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 harp:~ > cat a.rb def chomper until (xx = gets.chomp) == 'qq' puts "hit me with a squirell!" end xx end puts chomper 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! ;-) -a -- happiness is not something ready-made. it comes from your own actions. - h.h. the 14th dali lama