On Thu, 16 Apr 2009 18:02:52 -0500, Mike Stok <mike / stok.ca> wrote:


>> How do you get 101 from a[1]
>
>It's the value associated with the character e in ASCII.
>
>In irb:
>
> > RUBY_VERSION
>=> "1.8.6"
> >> a = 'hello'
>=> "hello"
> >> a[1]
>=> 101
> >> ?e
>=> 101
> >> a[1 ,1]
>=> "e"
> >>
>
>
>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#[]:
>
>irb(main):001:0> RUBY_VERSION
>=> "1.9.2"
>irb(main):002:0> a = 'hello'
>=> "hello"
>irb(main):003:0> a[1]
>=> "e"
>irb(main):004:0>
>
>Hope this helps,
>
>Mike

Its a great help!
Thanks Mike