From: Markus Date: 2004-09-21T23:33:44+09:00 Subject: Re: [Nuby Question] Return value of while loop. On Tue, 2004-09-21 at 03:44, Martin DeMello wrote: > Markus wrote: > > On Sat, 2004-09-18 at 12:44, Brian Schræ—¦der wrote: > > > > :~$ irb > > > > irb(main):001:0> (i *= 2) > 100 and break i while i = i || 1 > > > > => 128 > > > > > > You won, and I'm even able to grasp what you have written. So no > > > extra points for obfuscation ;) > > > > What were the criteria again? The declared winner > > The criterion was to "break i" on loop exit. Pardon me if I am being dense, but I still don't see what you are getting at. What is the magic of break i? Wouldn't any control structure that terminated the loop at the appropriate point and returned i (as the value of the expression) be just as acceptable? For example: (i += i while (i ||= 1) < 100) || i is semantically equivalent to (i *= 2) > 100 and break i while i = i || 1 so far as I can see. I tend not to use break (since it is "unstructured" in the GTCH sense) so forgive me if I am just missing some obvious property or well known behaviour of break. -- MarkusQ