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.)

>  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
-- 
Posted via http://www.ruby-forum.com/.