From: Chris Moline Date: 2001-08-15T05:06:59+09:00 Subject: [ruby-talk:19729] Re: class methods and optimizing On Wed, Aug 15, 2001 at 01:32:02AM +0900, Joseph McDonald wrote: > I don't know about memory usage or speed, but I would be wary of > changing (or adding to) the functionality of standard classes that > everyone relies on, because if your code gets used by someone else, it > may cause unexpected results. It would be nice if you could somehow > limit the scope of your changes to a class. That way, if you wanted > to change the way Array works, you can do it without breaking other > code used in the same program that changes Array in a different way. > I'm not sure if such a thing is possible or even considered a good > idea by matz, but I think it's a good idea for now... Well, I don't know if it would suit you but could you not inherit the class you want to modify into another class and then make the changes there and use the new class?? Ie class MyArray < Array def []( *args ) 1 end end mine = MyArray.new( 5, 10 ) yours = Array.new( 5, 10 ) puts mine[2] puts yours[2] In my opinion this is a nice way to do it, the only hard part is thinking up a decent name. Sincerly, Chris Moline