From: Gary Wright Date: 2011-09-14T12:07:40+09:00 Subject: Re: Need help regarding conditionals on while loops. On Sep 13, 2011, at 10:49 PM, Kane Williams wrote: > They never really explained how this works though: > >> while output The while loop body is executed if the expression evaluates to a true-ish value. In this case the expression is simply the local variable 'output'. In Ruby all values are considered true *except* for nil and false. In particular 0 is considered true as is an empty string, empty array, and empty hash ("", [], {}). This often trips up Ruby newcomers. So in your example > def doUntilFalse firstInput, someProc > input = firstInput > output = firstInput > > while output > input = output > output = someProc.call input > end > > input > end the while loop will continue iterating until someProc returns a false-ish value (either nil or false). The output of someProc is reused as its input for the next iteration. Gary Wright