From: Gavin Sinclair Date: 2002-12-13T15:24:08+09:00 Subject: Re: Inheritance Question From: "Jim Freeze" > On Friday, 13 December 2002 at 14:14:14 +0900, Gavin Sinclair wrote: > > From: "Jim Freeze" > > > > In effect, you are adding methods to the Matrix class, so why don't you ... ? > > > > class Matrix > > def all_my_wonderful_methods > > ... > > end > > end > > I like open classes, and use this feature for my own classes on occasions, > but I am opposed in principle to modifying standard classes. Even > though, one would still have problems since some of the methods you > would expect to return self don't. Thus you cannot chain methods when > you need to. > I don't blame you for not wanting to modify "standard" classes, but in this case I would consider Matrix to be a third-party class that happens to be packaged with Ruby. It's hardly essential for Ruby's operation (like String, Array, etc.). And if some of the methods can be plainly improved, I'd probably (for a simple class like Matrix) modify them directly, prove the superiority over the original with demonstrations in your code, and offer the improvements for inclusion in the standard library. That way you'd be using the standard class ahead of time! Cheers, Gavin