From: Robert Klemme Date: 2005-10-06T18:26:51+09:00 Subject: Re: techniques for module to contribute to initialize() of its including classes itsme213 wrote: > What are good design techniques for this e.g. if the module adds some > instance variables to its included class? > > module M > def f > @f > end > # how to initialize @f ? > end > > class A > include M > end > Thanks. Do it like this and the module initialite will seamlessly integrate into the class inheritance chain: module M def initialize(*a,&b) super @f = 10 end end There have been discussions about this http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/121611 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/129974 Kind regards robert