Possible duplicate:Is there a reason why we cannot sort out the “inverse range” in ruby?
It works like magic.
for i in 1..10 ... end
Is it not just intuitive that this reverse loop should work?
for i in 10..1 ... end
If there is a syntactic reason why this should not work, I feel that the ruby needs to be changed so that it can be done. It is just intuitive to write the opposite for a loop in this way.
1..10has a Range class that is not directly related to any loop constructs. And there are no numbers that are greater than 10 and less than 1, so the range is 10..1empty.
1..10
10..1
PS , for ruby. , - http://www.ruby-doc.org/core-1.9.2/Enumerable.html ?
-
10.downto(1) { |i| ... }