在Ruby中,可以显式创建局部变量
发布时间:2020-12-17 01:30:36 所属栏目:百科 来源:网络整理
导读:例如 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 = Pro
例如
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |