From: Michael Edgar Date: 2011-03-12T08:02:34+09:00 Subject: Re: Is an elsif loop possible? > and while loops are much clearer in meaning. That's a purely subjective point to make and, in my opinion, often untrue. while !x.nil? // body end vs. until x.nil? // body end is a simple example where I like the until version better. Once DeMorgan's law kicks in for certain negations, until loops can become much cleaner. Example: while !x.nil? || y < 0 // body end until x.nil? && y >= 0 // body end I personally think the until loop there is *much* simpler to read. Michael Edgar adgar@carboni.ca http://carboni.ca/ On Mar 11, 2011, at 5:57 PM, 7stud -- wrote: > Devin Rawlek wrote in post #986991: >> Thank you Steve. That was exactly what I needed. >> >> This works perfectly. >> >> $Str = gets.chomp >> $Str.to_i < 0 > > What is that line for? As written it does nothing: the comparison > evaluates to either true or false and then the value is discarded. > >> until $Str.to_i > 0 > > > Note that any until loop can be written as a while loop: > > while $Str.to_i <= 0 > > and while loops are much clearer in meaning. > > -- > Posted via http://www.ruby-forum.com/. >