Austin Ziegler wrote:
> On 10/2/07, Lars Ticot <nicolas.rassat / free.fr> wrote:
>> To Robert Klemme:
>> Sure I can do this but this way I lose every benefit of inheritance! And
>> I'll have to rewrite "accesor" function to access function to the
>> instance variable array. That is not very DRY.
> 
> No you don't. #method_missing and #respond_to? are your friends. Or
> you can use Delegator.

yes but:

a = NRArray.new
a.push(2)  #=> "pushing [2]"
a.pop #=> "poping []"

I don't want to catch the poping!

The delegator is an answer, like having an Array instance var. I lose 
the inheritance benefit.

It would have been great if, Array#push, Array#<< and Array#insert, 
would used the same Array#internal_insert in their implementation. So 
hooking this one would give me a hook on the other one. Basicaly they 
are all three doing insertion!

> (Note that NArray is a well-known numerical array extension, so Narray
> is likely to be confusing if you need it.)

Right! It was just the first name that came to me (N(ew)Array) when I 
start thinking at this problem ;-)

-- 
Posted via http://www.ruby-forum.com/.