From: Brad Hilton Date: 2002-09-12T08:22:07+09:00 Subject: instance_eval with a block Hello, Can someone please explain why the following code doesn't work? P.S. If I move the methods out of class 'TestEval', things work as expected. I'm guessing it has to do with Binding or some such trickery, but I'm stumped. Thanks, -Brad --------------- class TestEval def install_attrs(attrs) attrs.each { |k, v| type.send(:attr_accessor, k) send("#{k}=", v) } end def output(params, block) install_attrs(params) instance_eval { block.call } end end # class TestEval block = proc { @name } test = TestEval.new params = { 'name' => 'Joe', } puts test.output(params, block) params['name'] = 'Marty' puts test.output(params, block) -----------------------------------