From: William Morgan Date: 2005-07-07T07:54:17+09:00 Subject: Re: Inheriting Array and slice() behaviour Excerpts from Yukihiro Matsumoto's mail of 6 Jul 2005 (EDT): > on Wed, 6 Jul 2005 18:17:21 +0900, Sylvain Joyeux > writes: > > |I have a class inheriting Array, and I expected slice() and [] |to > return Array objects. > > Why? I'd expect them to return instances of the class of the > receiver, as Daniel does in [ruby-talk:147323], since they are ripped > part of the receiver. But #+ returns an Array. Is that consistent? Like the OP, I think it's weird and special-cased to have #slice magically return something with the receiver's class. Especially since the return value is going to be broken (not initialized) except in trivial cases. > Anyway, I'd suggest you not to subclass basic classes, unless you are > sure what you're doing. I don't think Expressions by no means have > is-a relationship to Arrays. Inheritance is not a panacea. Absolutely. -- William