From: Brian Candler Date: 2004-09-19T03:01:03+09:00 Subject: Re: [Nuby Question] Return value of while loop. On Sat, Sep 18, 2004 at 05:32:02PM +0100, Brian Candler wrote: > 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 Ah, I forgot ||= to initialise, so if you're counting lines rather than characters: i*=2 while (i||=1)<=x i Of course, i<<=1 might be microscopically faster. But it's also one character longer :-) Brian.