On Sat, 23 Dec 2000, Dave Thomas wrote:

> Dave Thomas <Dave / PragmaticProgrammer.com> writes:
> 
> Now, can anyone find a use for tacking a 'while' modifier on to a
> class or method definition?

Not exactly a use, in any meaningful sense.... but I'll be brave and,
for the greater good, share my little experiments.

My initial thought was to try to use the while construct to generate a
list of closures, or something in that line.  I never got that far (nor
am I sure that one could do exactly that this way).  So -- nothing
very grandiose, but my scratchpad looks like this:


   $var = 1

   def meth(v = $var)
     puts "v is #{v}"
   end while ($var += 1) < 5  # placeholder for something useful

   meth       # => "v is 5\n"


I can't really think of any case where this would be better than:

   $var += 1 while $var < 5
   def meth(v) .... end

but there may be a case where it is (?).


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav