views:

64

answers:

1

I have doubt whether we can achieve multiple inheritence using 'module' concept or Is there any other keywords or concepts which achieve multiple inheritence in ruby?

+4  A: 

Ruby supports mixin composition. A class can only inherit from one superclass, but it can mix in many modules.

That's not, strictly speaking, multiple inheritance, but it offers at least sharing of behavior across different classes.

Jörg W Mittag
And it's in my opinion much better than multiple inheritance.
Georg
However, MI is, in some sense, more powerful. Not in the computability theoretic Turing Machine sense, of course, but relating to expressivity: you can trivially implement mixins using MI (and, in fact, mixins are a pretty common idiom in Eiffel, Python and C++), but you can't implement MI using mixins. OTOH, it is quite easy to screw up MI very badly. *cough* C++ *cough* But, it's not impossible to get right as Eiffel clearly shows. Remember: if C++ is all you know, then judging MI is like judging all Americans when the only one you know is Glenn Beck or judging all cars by a Pinto.
Jörg W Mittag
I shouldn't have brought up a topic I'm not too familiar with, great comment. :)
Georg