From: Robert Klemme Date: 2010-10-21T17:00:50+09:00 Subject: Re: about handling args in block On Thu, Oct 21, 2010 at 6:10 AM, w_a_x_man wrote: > On Oct 20, 11:41 am, Robert Klemme wrote: > >> Node = Struct.new :value, :left, :right do >> >>    # We usually do not use prefix "is" which >>    # you might be used to in Java. >>    def leaf? >>      @left.nil? && @right.nil? >>    end > > Will that work? Or would it have to be > >    self.left.nil? && self.right.nil? No, my code won't work. But this is sufficient: left.nil? && right.nil? It also needs to be def visit(val = nil, &b) val = left.visit(val, &b) if left val = b[self, val] val = right.visit(val, &b) if right val end Thanks for catching this! Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/