H
Harry Spier
Dear list members,
(5..1).to_a #returns []
(1..5).to_a #returns [1,2,3,4,5]
(5..1).each{|x| puts x} #prints (-5..-1)
(1..5).each{|x| puts x} #prints
1
2
3
4
5
I don't get an error message when I declare a descending Range or when I
apply an iterator method to it, but I'm not able to iterate over a
descending Range the same way I can an ascending Range. Can someone
explain what the rationale is behind that language restriction?
Thanks,
Harry
(5..1).to_a #returns []
(1..5).to_a #returns [1,2,3,4,5]
(5..1).each{|x| puts x} #prints (-5..-1)
(1..5).each{|x| puts x} #prints
1
2
3
4
5
I don't get an error message when I declare a descending Range or when I
apply an iterator method to it, but I'm not able to iterate over a
descending Range the same way I can an ascending Range. Can someone
explain what the rationale is behind that language restriction?
Thanks,
Harry