标签:turn 不能 color dup code pre 单例 end object
ruby中clone和dup都是对一个对象的浅拷贝,其区别如下: 1.clone会拷贝单例方法,而dup不会。 a = Object.new def a.hello "hello" end a.dup.hello # raises NoMethodError a.clone.hello # return "hello" 2.dup不能对frozen状态的对象进行拷贝,而clone可以
标签:turn 不能 color dup code pre 单例 end object
原文地址:http://www.cnblogs.com/znsongshu/p/6080599.html