From: Brian Candler Date: 2004-09-19T01:32:13+09:00 Subject: Re: [Nuby Question] Return value of while loop. On Sat, Sep 18, 2004 at 05:44:44PM +0900, Brian Schrder wrote: > PS: If you want you can see this as a warmup for our first Quiz ;). What > is the most concise way to write this: > > i = 1 > loop do > i *= 2 > break i if i > 100 > end > > which would simulate the behaviour I'd expect of the 2-liner above. (No > semicolons allowed) I can do that in 5 characters plus a newline: i=128 :-) Perhaps you should reword your question as: # x is initialised to an Integer i = 1 loop do i *= 2 break i if i > x end in which case the smallest I can think of is: i=1 i*=2 while i<=x i (the third line being necessary since you want the answer to be the value of the overall expression, not just being left in 'i') Regards, Brian.