This behavior has changed in Ruby 1.9 to become more consistent with the behavior of the other variants of the index operator. For example, "test"[0,2] returns the string "te", the first two characters of "test".
Why should the the single integer variant behave differently?
This has been changed in Ruby 1.9. The statement "test"[0] will return the single character string "t".
#!/usr/bin/env ruby# In Ruby 1.8, this will return 116 # In Ruby 1.9, this will return "t" puts "test"[0]