diff --git a/guides/source/active_support_core_extensions.textile b/guides/source/active_support_core_extensions.textile index ab5ceaf2b391d8ab79c3eadace1d342e569d17b0..c56cb0b9e50f94d157d357a9e841e3c12c8e46e9 100644 --- a/guides/source/active_support_core_extensions.textile +++ b/guides/source/active_support_core_extensions.textile @@ -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'] @@ -179,7 +181,7 @@ If you need a deep copy of an object, you should use +deep_dup+ in such situatio array = ['string'] -duplicate = array.dup +duplicate = array.deep_dup duplicate.first.gsub!('string', 'foo')