I
Intransition
Is there any way to get a hold of the current block? I've been playing
around with recursive enumerations and it occurs to me that the most
flexible technique would simply be to reuse the currently running
block.
For example, where `this` would be the current block:
h = {:a=>1, :b=>{:c=>3}}
h.map{ |k,v| Hash===v ? [k.to_s, v.map(&this)] : [k.to_s,v.to_s] }
#=> {"a"=>"1", "b"=>{"c"=>"3"}}
around with recursive enumerations and it occurs to me that the most
flexible technique would simply be to reuse the currently running
block.
For example, where `this` would be the current block:
h = {:a=>1, :b=>{:c=>3}}
h.map{ |k,v| Hash===v ? [k.to_s, v.map(&this)] : [k.to_s,v.to_s] }
#=> {"a"=>"1", "b"=>{"c"=>"3"}}