标签: ruby local-variables
如何通过名称访问变量?
a = Hash.new a["test"] = 9 some_method(:a) # => {"test" => 9}
答案 0 :(得分:3)
a = Hash.new a["test"] = 9 binding.local_variable_get(:a) # => {"test"=>9}