If you look at the ri documnetation for String# in Ruby 1.8.6 you can see:
-------------------------------------------------------------- String#
str[fixnum] => fixnum or nil
str[fixnum, fixnum] => new_str or nil
str[range] => new_str or nil
str[regexp] => new_str or nil
str[regexp, fixnum] => new_str or nil
str[other_str] => new_str or nil
[...]
···
On Apr 16, 2009, at 6:40 PM, Reg wrote:
------------------------------------------------------------------------
Element Reference---If passed a single +Fixnum+, returns the code
of the character at that position.
[...]
In Ruby 1.9 things change so that you always get a String or nil back from String#:
If you look at the ri documnetation for String# in Ruby 1.8.6 you
can see:
-------------------------------------------------------------- String#
str[fixnum] => fixnum or nil
str[fixnum, fixnum] => new_str or nil
str[range] => new_str or nil
str[regexp] => new_str or nil
str[regexp, fixnum] => new_str or nil
str[other_str] => new_str or nil
[...]
------------------------------------------------------------------------
Element Reference---If passed a single +Fixnum+, returns the code
of the character at that position.
[...]
In Ruby 1.9 things change so that you always get a String or nil back
from String#: