From: "Matthias Wächter" Date: 2007-09-03T18:49:26+09:00 Subject: Re: Ruby stupidities On 31.08.2007 05:24, Kenneth McDonald wrote: > Having said that, here's my first entry. I think it's utterly stupid > (can you tell I just wasted some time tracking this down?) that > > "abc"[0] == "a" You can change that behavior yourself without installing >=1.9 class String alias :old_index :[] def [](*a) a.length==1 ? old_index(*a).chr : old_index(*a) end def asc # this is from [1] case size when 0; nil when 1; old_index(0) else unpack 'c*' end end end "abc"[0] == "a" # -> true "abc"[1] == "b" # -> true "abc"[0,1] == "a" # -> true "a".asc == 97 # -> true "abc".asc == [97,98,99] # -> true But certainly this may break existing libs, so be careful. [1] http://forum.ruby-portal.de/viewtopic.php?p=2654#2654 - Matthias