aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-12 14:29:11 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-12 14:29:11 -0700
commite68b97a4b65787711e50aa1565b4dd0077a00d6d (patch)
tree229a43700512aed4a8713c09afac293622951f89 /guides/source
parent3e75369b7263a0ec09c45dd1371b1641797e9604 (diff)
parenta4b11961630febd556c962b788b11c0ed5bedb45 (diff)
downloadrails-e68b97a4b65787711e50aa1565b4dd0077a00d6d.tar.gz
rails-e68b97a4b65787711e50aa1565b4dd0077a00d6d.tar.bz2
rails-e68b97a4b65787711e50aa1565b4dd0077a00d6d.zip
Merge pull request #7007 from Mik-die/hash_extract
make Hash#extract! more symmetric with Hash#slice
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_support_core_extensions.md12
1 files changed, 10 insertions, 2 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 645498437d..f990b4f79f 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -2867,8 +2867,16 @@ The method `extract!` removes and returns the key/value pairs matching the given
```ruby
hash = {:a => 1, :b => 2}
-rest = hash.extract!(:a) # => {:a => 1}
-hash # => {:b => 2}
+rest = hash.extract!(:a, :x) # => {:a => 1} # non-existing keys are ignored
+hash # => {:b => 2}
+```
+
+The method `extract!` returns the same subclass of Hash, that the receiver is.
+
+```ruby
+hash = {:a => 1, :b => 2}.with_indifferent_access
+rest = hash.extract!(:a).class
+# => ActiveSupport::HashWithIndifferentAccess
```
NOTE: Defined in `active_support/core_ext/hash/slice.rb`.