From: Joel VanderWerf Date: 2008-08-09T04:30:06+09:00 Subject: Re: ruby wish-list 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 > } > > without resorting to ugly syntax like > > [[1,2,[3]],[[[5],6],7],8].map &(deep_to_s = proc { |e| > Array === e ? e.map(&deep_to_s) : e.to_s > }) > IIUC, this would also let us take this idiom: pr = proc {|h,k| h[k] = Hash.new(&pr)} h = Hash.new(&pr) h[1][2][3] = 6 p h # ==> {1=>{2=>{3=>6}}} and simplify to: h = Hash.new {|h,k| h[k] = Hash.new(¤t_block)} -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407