From: Joseph McDonald Date: 2001-08-15T05:25:09+09:00 Subject: [ruby-talk:19734] Re: class methods and optimizing CM> Well, I don't know if it would suit you but could you not inherit the class you CM> want to modify into another class and then make the changes there and use the CM> new class?? Ie CM> class MyArray < Array CM> def []( *args ) CM> 1 CM> end CM> end CM> mine = MyArray.new( 5, 10 ) CM> yours = Array.new( 5, 10 ) CM> puts mine[2] CM> puts yours[2] CM> In my opinion this is a nice way to do it, the only hard part is thinking up a CM> decent name. Yes, that works, but what if I want to install some "cheaters" such as: class NilClass def +(other) other end end a = {} # yes, I could do a = Hash.new(0)... a["key"] += 1 # no need to initialize puts a["key"] # no need to initialize j += 1 puts j I guess some people would say: "Don't do that!" Which I guess is an option :-) There are probably other legitimate reasons to change the workings of "standard" classes for the scope of methods defined in a file. thanks, -joe