On 2004-09-18, Kristof Bastiaensen <kristof / vleeuwen.org> 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 > > Here is a oneliner: > i = 128 I can do better in two different ways: $i <<= 1 while defined?($i) ? ($i < 100) : ($i = 1) or worse, my entry for a future Ruby's obfuscated code contest: i = (i ? i : 1) * 2 while defined?(i) ? ((i ? i : 1) < 100) : (i = 1) But there is a strange behaviour I don't understand, if I try: i <<= 1 while defined?(i) ? (i < 100) : (i = 1) the variable i is 'defined' but set to nil, that's why the previous line won't work as expected... -- Olivier D.