From: Shilesh Kumar Date: 2008-09-17T16:57:28+09:00 Subject: Re: SuperClass and Modules James Coglan wrote: >> >> Multiple inheritance has one big problem usually denominated as "the >> diamond problem". Check this link: >> http://en.wikipedia.org/wiki/Diamond_problem. >> Ruby using single inheritance plus mixins gives almost the same >> advantages without these problems. > > > > You cannot have multiple inheritance without the diamond problem -- that > page actually mentions how Ruby resolves method names in this case: > > module A; end > module B; include A; end > module C; include A; end > > class D > include B > include C > end > > Methods will be looked up in D, C, B and A (in that order) when you call > a > method on an instance of D. Thanks James and Pedro, I understood the diamond problem. let me clarify myself. To avoid the method confusion while having more than one module, Ruby looks in a particular order. This can be applied in the case of super classes as well and let ruby follow the order of import while searching for a method. Thus i may have, class MyClass < A < B #[oder of method search will be from MyClass, A to B] I believe that there might be some strong reason for allowing multiple Modules while restricting only one Parent ...? -- Posted via http://www.ruby-forum.com/.