From: Christoph Date: 2002-04-13T14:59:02+09:00 Subject: Re: Rudy idiom for enumeranting parents of a node? "Pete McBreen" wrote in .... > > I though that this one would be easy to answer until I realized that > although there is a #block_given? method I don't know how to refer to an > anonymous given block. A very crude hack is to say > > class Node > def initialize(parent, children=[]) > @parent = parent > @children = children > @children.each { |child| child.parent(self) } > end > def parents (*unused_args, &block) > @parent.parents &block unless @parent.nil? > yield self > end def parents @parent.parents {|x| yield x } unless @parent.nil? yield self end > .... /Christoph