"Ernest Ellingson" <erne / powernav.com> wrote in message
news:4.3.2.7.2.20001229193449.03f6e4c0 / powernav.com...
> Being new to Ruby, I don't understand how you are using the non inclusive
> range operator.  Could you elaborate with more of a code snippet?
This code uses no Ranges at all. Are you thinking about something
like this.

p   ("A".."D").type      # Range
versus
p  "ABCD".type   # String

The Range object "A".."D" is very different from the String object "ABCD".
You can form an in(ex)clusive  Range object   r = obj1..obj2  whenever obj1
and obj2 are comparable.  The way Ruby iterates over the range relies
on the behavior of the #succ(essor) method. For example,

"A".succ == "B"  ;  "B".succ == "C'; "C".succ == "D".

which happen to be the same as the letters of the String   "ABCD"
but you can also iterate over the letters of the word  "ADBC"  ...

("A".."D").each do |i| p i end            #  the output are strings hence
`newlines'
 "ABCD".each do |i| p i end            #   the letters of "ABCD"
"ADCB".each do |i| p i end             #   the letters of "ADCB"
"ABCD".each_byte do |i| p i end  #   the ansi representation
                                                         # of the  letters
of "ABCD"
# Has the output
"A"
"B"
"C"
"D"
"ABCD"
"ADCB"
65
66
67
68


Christoph