Difference between [0..0] and [0]

Strings are not treated the same as arrays. A single number in the
brackets gives you the ASCII value of the character at that position.
If you want the first character, I'd use @string[0,1] which gives you
a substring starting at the 0th position, with a length of 1.

BUT, this will change in Ruby 2.0 so that "abc"[0] will be "a" rather than 97

It seems to be true that "something"[n] is the same value as "something"[n..n][0] for all n


Rob Biedenharn http://agileconsultingllc.com