From: Daniel Brockman Date: 2005-07-28T09:52:04+09:00 Subject: Re: What's so special about operators, built-in classes and modules? Pit Capitain writes: > For me, the main difference between modules and classes is > that classes "define" state (instance variables), not only > behaviour (methods). Yet there are many examples of modules whose modules set instance variables, and there are many examples of classes whose methods do not. That alleged difference is not grounded in reality. > One classic problem with multiple inheritence is the so > called diamond: > > class A > def initialize(val) > @var = val > end > end > > class B > include A > def initialize > super(5) > end > end > > class C > include A > def initialize > super(42) > end > end > > class D > include B > include C > end > > d = D.new As has been pointed out countless times already, the diamond inheritance problem already exists in Ruby: module A def initialize(val) @var = val end end module B include A def initialize super(5) end end module C include A def initialize super(42) end end class D include B include C end > Now, how many instances of A are in d? One (assuming you mean how many are in D's ancestor list). -- Daniel Brockman