From: Siep Korteling Date: 2008-05-30T07:28:45+09:00 Subject: Re: Quickie: Monkey patching Array Leon Bogaert wrote: > I know it's bad behaviour :) But I'm just fiddling with ruby. > > class Array > def [](elem) # just get rid of the "=" > raise 'Yesss... It works!' > end > end > > a = ['one', 'two', 'three'] > p a > > Didn't work also. It just prints: ["one", "two", "three"] try p a[0] [] is just a method. You chanced it. To verify if your change works, you 'll have to use the [] method. If this is not what you want, what outcome did you expect? regards, Siep -- Posted via http://www.ruby-forum.com/.