提交 3ac93d66 编写于 作者: P Piotr Sarnacki

[guides] Add comments to deep_dup example, fix second example [ci skip]

上级 b41bfb04
......@@ -164,11 +164,13 @@ duplicate = array.dup
duplicate.push 'another-string'
# object was duplicated, element added only to duplicate
array #=> ['string']
duplicate #=> ['string', 'another-string']
duplicate.first.gsub!('string', 'foo')
# first element was not duplicated, it will be changed for both arrays
array #=> ['foo']
duplicate #=> ['foo', 'another-string']
</ruby>
......@@ -179,7 +181,7 @@ If you need a deep copy of an object, you should use +deep_dup+ in such situatio
<ruby>
array = ['string']
duplicate = array.dup
duplicate = array.deep_dup
duplicate.first.gsub!('string', 'foo')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册