Marnen Laibow-Koser wrote:
> Michael W. Ryder wrote:
> [...]
>> But if you wanted to do something like:
>>    i = 10;
>>    while (i > 0)
>>    {
>>      printf("%d/n", i--);
>>    }
>> in Ruby you would have to do something like:
>>    i = 10
>>    while (i > 0)
>>      puts i
>>      i -= 1
>>    end
> 
> No.
> 
> 10.downto(1) do |i|
>   puts i
> end
> 
>> As far as I can tell there is no way in Ruby to use .each or .times to
>> go backwards.
> 
> That's what .downto is for.  (Have you ever needed this?  I have not.)
> 

I missed the downto method, I guess that is a problem when you have so 
many different ways to do the same basic things.  I much prefer the 
simplicity of Basic and C with for loops that can go either direction. 
As far as going backwards I use it a lot to parse strings of the form 
"city name ST 12345-6789" to City, State, and Zip Code fields.  I look 
for the first blank from the end of the string and assume everything 
after it is the Zip Code, I then find the next two non-blank characters 
and assign them to State, and everything else is the City name.

>>  While I realize this thread is about the ++ operator the
>> -- operator is complementary.
>>
>> <snip>
> 
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> marnen / marnen.org