Hi,

Am Montag, 26. Okt 2009, 21:17:17 +0900 schrieb Robert Klemme:
> 2009/10/26 salai <sayakyi / gmail.com>:
> >  > >  > >    
> >  > >    > 
> The line above should read acc += 1.  You could even simplify that as
> 
> acc += (x.number_of_leaves rescue 1)
> 
> >  
> >  

I prefer doing it with `case'. I admit I did no performance check.

  inject( 0) { |acc,x|
    acc += case x
      when Array then   x.number_of_leaves
      else              1
    end
  }

Bertram

-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de