From: Robert Dober Date: 2010-04-17T06:44:30+09:00 Subject: Re: Is it possible, a fully general Enumerable#recursive ? On Fri, Apr 16, 2010 at 11:20 PM, Colin Bartlett wrote: >   "After working on this for far too long, I have concluded that >    a highly generalized implementation of recursion for all >    (or at least most) enumerable methods not feasible.") I beg to differ module Enumerable def recursive_each &blk each do | ele | Enumerable === ele ? ele.recursive_each(&blk) : blk[ele] end end def rec_enum; enum_for :recursive_each end end x=[ :a, 42, [:b, :c], {:a=> 42, :b => [1,2]}] rx = x.rec_enum p rx.to_a p rx.any?{ |x| x > 41 rescue false } p rx.map{ |x| "<#{x}>" }.join(", ") Cheers R. -- The best way to predict the future is to invent it. -- Alan Kay