diff options
Diffstat (limited to 'guides/source/active_support_core_extensions.textile')
-rw-r--r-- | guides/source/active_support_core_extensions.textile | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/guides/source/active_support_core_extensions.textile b/guides/source/active_support_core_extensions.textile index ab5ceaf2b3..c56cb0b9e5 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'] </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') |