Answer to the three responses:
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.
To Joel VanderWerf:
Your remark about Array#+ is completly right. I just put it here to test
if Array#push or Array#<< were implementing using the Array#+ function.
To Logan Capaldo:
I got this error:
narray.rb:9:in `method_missing': undefined method `append' for [1,
2,3]:Narray (NoMethodError)
from narray.rb:32
But this is not the point. This way I'll catch every func, not just func
that insert something on the array. I would have to do something like my
example. Again, this is not really DRY.
Does anyone knows how insertion is implementing in the ruby core code or
should I dig the code by myself? This time is about inserting into an
array, but it can be over action; would it not be great to have some
hook function to solve easily this kind of problem?
To all you three, thanks for your answer
--
Posted via http://www.ruby-forum.com/.