On Fri, 5 May 2006, polypus wrote: > ok for those who like pointless exercises here is a harder version. > > rules: > > 1) you may replace the elipses with any amount of code but may not alter > any other part of the code listing > 2) when the program is run it must return, i.e. X.new must evaluate to > an instance of class X > 3) foo must be called as an instance method of an instance of X and > print something like #<X:0xb7e188a4> > 4) you may not use class_eval, module_eval, or use the extend_object > callback > > module N > def foo > puts self > end > end > > module M > ... > end > > class X > extend M > end > > X.new > > yes there is a solution, good luck harp:~ > cat a.rb module N def foo() puts self end end module M def new(*a, &b) obj = super obj.extend N obj.foo obj end end class X extend M end X.new harp:~ > ruby a.rb #<X:0xb75d196c> -a -- be kind whenever possible... it is always possible. - h.h. the 14th dali lama