使用 eval 分配实例变量可以正常工作,而另一个则不能。试图了解这里发生了什么。任何帮助表示赞赏。
>> var = "a value"
=> "a value"
>> @v
=> nil
>> eval "@v = var"
=> "a value"
>> @v
=> "a value"
>> eval "var_new = var"
=> "a value"
>> var_new
NameError: undefined local variable or method `var_new' for main:Object
from (irb):7
from C:/Ruby193/bin/irb:12:in `<main>'