Gavin Kistner
5/17/2007 10:57:00 PM
On May 17, 3:40 pm, "Giles Bowkett" <gil...@gmail.com> wrote:
> Quick thing - I know Array is implemented in C rather than in Ruby.
> This is probably true for Hash as well. There's two points here:
> first, if you were patching Array directly, you could rewrite [] and
> it would still drop to the C implementation (if I understand
> correctly).
a = [1,2,3]
def a.[]( bar )
"You want element #{bar.inspect}? Too bad!"
end
puts a[2]
#=> You want element 2? Too bad!
p a.class
#=> Array