diff options
author | Xavier Noria <fxn@hashref.com> | 2013-11-24 20:00:24 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2013-11-24 20:00:24 +0100 |
commit | 17c29a0df0da5414570b025b642e90968e96cddc (patch) | |
tree | de1fd00eb2df79bf6bdcaeb74cc17365eaa53e33 /guides/source/active_support_core_extensions.md | |
parent | b4b30c048d22b14d51cc2f0f5b397bf899a9ce49 (diff) | |
parent | 28a6a7ea3bd627a8b6693a4cb8305b89467592b4 (diff) | |
download | rails-17c29a0df0da5414570b025b642e90968e96cddc.tar.gz rails-17c29a0df0da5414570b025b642e90968e96cddc.tar.bz2 rails-17c29a0df0da5414570b025b642e90968e96cddc.zip |
Merge remote-tracking branch 'docrails/master'
Conflicts:
activesupport/lib/active_support/core_ext/hash/deep_merge.rb
activesupport/lib/active_support/core_ext/hash/keys.rb
Diffstat (limited to 'guides/source/active_support_core_extensions.md')
-rw-r--r-- | guides/source/active_support_core_extensions.md | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 84a169b3b9..452ddf01eb 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -179,14 +179,14 @@ duplicate = array.dup duplicate.push 'another-string' # the object was duplicated, so the element was added only to the duplicate -array #=> ['string'] -duplicate #=> ['string', 'another-string'] +array # => ['string'] +duplicate # => ['string', 'another-string'] duplicate.first.gsub!('string', 'foo') # first element was not duplicated, it will be changed in both arrays -array #=> ['foo'] -duplicate #=> ['foo', 'another-string'] +array # => ['foo'] +duplicate # => ['foo', 'another-string'] ``` As you can see, after duplicating the `Array` instance, we got another object, therefore we can modify it and the original object will stay unchanged. This is not true for array's elements, however. Since `dup` does not make deep copy, the string inside the array is still the same object. @@ -199,8 +199,8 @@ duplicate = array.deep_dup duplicate.first.gsub!('string', 'foo') -array #=> ['string'] -duplicate #=> ['foo'] +array # => ['string'] +duplicate # => ['foo'] ``` If the object is not duplicable, `deep_dup` will just return it: @@ -1554,7 +1554,7 @@ ActiveSupport::Inflector.inflections do |inflect| inflect.acronym 'SSL' end -"SSLError".underscore.camelize #=> "SSLError" +"SSLError".underscore.camelize # => "SSLError" ``` `camelize` is aliased to `camelcase`. |