From: Adam Shelly Date: 2008-08-09T03:19:34+09:00 Subject: Re: ruby wish-list On 8/8/08, Mikael Høilund wrote: > Perhaps a bit controversial, but I'd like to see a keyword for the "current > block" as a way to refer to the Proc instance created inside that block. > That would allow for recursive anonymous blocks like: > > [[1,2,[3]],[[[5],6],7],8].map { |e| > Array === e ? e.map(¤t_block) : e.to_s > } > It's not exactly the same, but couldn't you just define a recursive map function? class Array def map_r &block map{|e|Array===e ? e.map_r(&block) : block[e]} end end p [[1,2,[3]],[[[5],6],7],8].map_r{|e|e.to_s} => [["1", "2", ["3"]], [[["5"], "6"], "7"], "8"]