From: Devin Mullins Date: 2005-07-08T22:17:06+09:00 Subject: Re: Inheriting Array and slice() behaviour Pit Capitain wrote: > See http://en.wikipedia.org/wiki/Liskov_substitution_principle for a > short definition. According to this principle, the subclass doesn't > have to have exactly the same initialize as the parent class, but it > has to support at least the same interface. Wrong. The LSP says that /objects/ of a subtype have to support the same interface. That is, it specifically ignores the constructor. That's how Java gets away with not inheriting the constructor. Of course, Ruby *does* inherit the constructor, so you can just tell people that want to derive from Array not to define initialize, or to do it in a way that doesn't suck, as you mentioned in the rest of your email. In that case, I suggest what I suggested previous: >Array has a "copy constructor" (Array.new can take another Array), so you could call klass.new(theNewSubArray) unless klass == Array, instead of just massaging it into a klass... > But in truth, I agree most with William Morgan: >In short, the current #slice behavior is a) wrong in non-trivial cases, >b) magic, and c) inconsistent with #+ and other methods. > Devin Sorry to shout "Wrong," like that. It's just I get so few opportunities to be absolutely confident in my answer. :)