例如 x = 123p = Proc.new { x = 'I do not want change the value of the outer x, I want to create a local x'} 在Ruby中是否有与Perl中的“my”关键字相同的东西? 根据 my 的Perl文档,我认为你在Ruby中寻找类似下面
x = 123 p = Proc.new { x = 'I do not want change the value of the outer x, I want to create a local x' }
在Ruby中是否有与Perl中的“my”关键字相同的东西?
根据 my的Perl文档,我认为你在Ruby中寻找类似下面的内容: –x = 123 p = Proc.new {|;x| x = 'I do not want change the value of the outer x, I want to create a local x' } p.call # => "I do not want change the value of the outer x, I want to create a local x" x # => 123