On Mar 17, 2007, at 5:10 PM, hurcan solter wrote: > Although I am a seasoned C/C++ programmer(+10 years), I am relatively > new to the ruby (about 2 days) despite having some reservations(ruby > debugger should be theslowest thing in the world) i am otherwise very > impressed with the language, I intend to use Ruby for some code > generation task ,Everything was going well until i hit that roadblock > > class REXML::Element > include TSort > def initialize > @dependencies=[] > end > def tsort_each_node(&block) > @elements.each(&block) > end > def tsort_each_child(node, &block) > @dependencies.each(&block) if @dependencies.size>0 > end > end Just a guess but I suspect your problem is that you've effectively thrown away the initialize method for REXML::Element and replaced it with your own. I think you want: alias __original_initialize initialize def initialize(*args, &block) __original_initialize(*args, &block) @dependencies = [] end This way you make sure the original version of initialize executes as well as your new code. Gary Wright