From: matz@... (Yukihiro Matsumoto) Date: 2001-01-10T15:44:54+09:00 Subject: [ruby-talk:8993] Re: Ranges inside brackets for arrays Hi, In message "[ruby-talk:8989] Ranges inside brackets for arrays" on 01/01/10, "Hal E. Fulton" writes: |Only later did I think, "Wait a minute. A |range can't go backwards..." | |I don't recall seeing an example like this |documented. | |Is the thing in the brackets "not really a |range" or what? What is going on here? The truth are: * A range enumeration cannot go back, it's upward only. * But A range with end point less than start point is valid. * Thus 1..-1 is a completely valid range object. * Array and String internally convert negative end point into size+n, where n is a negative number. * So range n..-m is interpreted as n..(size-m), thus works fine (if n <= (size-m)). QED. ;-) matz.