1
oaix 2014-11-27 21:00:51 +08:00
楼主是怎么得到这个疑问的。把测试代码发出来看看。我使用没有你说的问题。
```ruby ➜ ~ irb >> a = {a: 1} => {:a=>1} >> a => {:a=>1} >> b = a => {:a=>1} >> b[:b] = 2 => 2 >> b => {:a=>1, :b=>2} >> a => {:a=>1, :b=>2} >> b[:a] = 2 => 2 >> a => {:a=>2, :b=>2} >> b => {:a=>2, :b=>2} >> ➜ ~ ruby -v ruby 1.9.3p448 (2013-06-27) [i386-cygwin] ``` |
2
royzhanggy OP @oaix 写个脚本,写个函数,把哈希作为参数传进去,然后在函数里进行变量赋值,就会变成引用传递了....我也不懂为嘛会这样
|
3
oaix 2014-11-27 23:36:38 +08:00
@royzhanggy 直接赋值也是引用传递。
|