From: ts Date: 2002-02-05T00:04:57+09:00 Subject: Re: Mixins and accessing earlier definitions. >>>>> "H" == Hugh Sasse Staff Elec Eng writes: H> subclass in between including successive modules. I think this is H> because included modules appear as superclasses of the class that H> includes them. Yes, this is something like this. For example with class A end the inheritance of A is A < Object Now if you include the module B, this will give class A; include B; end A < [B] < Object [B] is a proxy class to the module B When an object of A call a method, ruby will look in A, then B, etc H> If a module is intended to {override or add} a method, how should this H> be done in idiomatic Ruby? Obviously my way of thinkig is wrong :-). H> I think using alias in the case where a method is added could be a H> problem, because the old method to be aliased will not exist. Well, you don't have this problem with 'include', for example if you want to redefine a method of Object (like to_s) for A, but using a module you just write module B def to_s "B::" + super end end class A include B end A.new.to_s When #to_s is invoked, ruby first search in A, then in B where it find it The call to #super in B, will force ruby to continue the search and call the original method of Object H> Also, several successive overrides could be a problem using alias. It's best to test if a method exist before trying to define un alias, otherwise you can create infinite loop. Guy Decoux