From: "shreeve (Steve Shreeve)" Date: 2012-10-15T22:01:14+09:00 Subject: [ruby-core:48005] [ruby-trunk - Bug #1926] Different eval/binding behaviour in 1.9 Issue #1926 has been updated by shreeve (Steve Shreeve). Given this change, what is the proper method of setting a local variable in a specific binding? ---------------------------------------- Bug #1926: Different eval/binding behaviour in 1.9 https://bugs.ruby-lang.org/issues/1926#change-30769 Author: candlerb (Brian Candler) Status: Rejected Priority: Normal Assignee: ko1 (Koichi Sasada) Category: Target version: 1.9.2 ruby -v: ruby 1.9.2dev (2009-07-18 trunk 24186) [i686-linux] =begin In 1.8.6, you can set a local variable in a binding using eval. This doesn't seem to work in 1.9.2-preview1. def define_a(b) eval "a=1", b end define_a(binding) puts local_variables.inspect # 1.8: prints ["a"] # 1.9: prints [] Similarly: def another_a(&blk) eval "a=1", blk.binding yield end another_a do puts local_variables.inspect end # 1.8: prints ["a"] # 1.9: prints [] =end -- http://bugs.ruby-lang.org/