From: Jean-Hugues ROBERT Date: 2004-05-04T15:42:05+09:00 Subject: Re: The code I forgot to include At 21:04 03/05/2004 +0900, you wrote: >Hi, > >On Mon, 03 May 2004 20:23:39 +0900, Jean-Hugues ROBERT wrote: > > So I tried: > > class MyArray < Array > > def self.[](*a); super[*a] end > > end > > x = MyArray[1,2,3] # => NoMethodError: super: no superclass method '[]' > > I don't understand what is happening because obviously Array.[]() > > exists. In fact it is the only class method defined by Array: > > Array.methods( false) # nota: false to avoid inherited methods, not > in my > > Pickaxe > > MyArray.methods( false) # => ["[]"] in both cases. > >Perhaps that's because super works only as a method (not as an object). >Try this: >class MyArray < Array > def self.[](*a); super(*a) end >end >Kristof Thanks. I obviously was "perhaps" wrong ;-) Now I get a better understand about why callable's [] is equivalent to .call() ! They really look similar. I knew there was a bug in my code because I had applied Sherlock Holmes' method: "Eliminate all other factors, and the one which remains must be the truth." -- The Sign of the Four I just could not see it. Thanks again. Yours, Jean-Hugues ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17