Ruby - Using while and until in a single line code

Description

Using while and until in a single line code

Demo

i = 1 
i = i * 2 until i > 1000 
puts i

Result

The value of i is doubled over and over until the result is over 1000, at which point the loop ends (1024 being 2 to the power of 10).

Related Topic