From: Chris Richards Date: 2007-11-27T19:15:25+09:00 Subject: Re: Metaprogramming help Wow, thanks for all your replies. > BTW: To ensure a routine always runs on initialization despite > #initialize, one way: > > class X > class << self > def new(*a, &b) > o = allocate > o.do_your_thing > o.initialize(*a,&b) > o > end > end > end > > The other is AOP which is a much larger can of worms. so whats the simplest way to ensure this method was always run ? : def initialize(x=0, y=0) self.x_position=x self.y_position=y end Thanks Chris -- Posted via http://www.ruby-forum.com/.