From: Andrew Wagner Date: 2010-10-24T02:43:59+09:00 Subject: Re-naming a block --001636d34c44af709004934c4df0 Content-Type: text/plain; charset=UTF-8 Hi all. I'm writing a method which takes a block and returns a lambda which will execute that block when called. Here's the code: def foo &block Proc.new { yield } end a = foo { 3 } puts a This returns something like #. That's all well and good, but what I'd really like is for that line number to show up as 5, since that's where the block is actually defined. So I try this: def foo &block a = Proc.new { yield } def a.to_s block.to_s end a end a = foo { 3 } puts a But here, ruby tells me that 'block' is undefined inside a's to_s. It's clearly not creating the closure I'd hoped for. I've played around with a few variations, but can't seem to get it to do what I want. Suggestions? --001636d34c44af709004934c4df0--