aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-11-20 18:22:00 -0500
committerGitHub <noreply@github.com>2018-11-20 18:22:00 -0500
commit9fb53e7b198a0b497566f06ba938d66502fa4326 (patch)
treeee5114054f98ed3d3fd912ec0b8561e1020b2ee1 /activesupport
parent4800fd072f2a8349e92cf9386da4b66de712a669 (diff)
parent4fa6a5c4e02bf6c511ecda9db4fd61e51634fe06 (diff)
downloadrails-9fb53e7b198a0b497566f06ba938d66502fa4326.tar.gz
rails-9fb53e7b198a0b497566f06ba938d66502fa4326.tar.bz2
rails-9fb53e7b198a0b497566f06ba938d66502fa4326.zip
Merge pull request #34497 from 6temes/make_documentation_for_slice_more_explicit
Expand documentation for Hash#slice!
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/slice.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb
index 2bd0a56ea4..fb5887d57b 100644
--- a/activesupport/lib/active_support/core_ext/hash/slice.rb
+++ b/activesupport/lib/active_support/core_ext/hash/slice.rb
@@ -27,8 +27,9 @@ class Hash
# Replaces the hash with only the given keys.
# Returns a hash containing the removed key/value pairs.
#
- # { a: 1, b: 2, c: 3, d: 4 }.slice!(:a, :b)
- # # => {:c=>3, :d=>4}
+ # hash = { a: 1, b: 2, c: 3, d: 4 }
+ # hash.slice!(:a, :b) # => {:c=>3, :d=>4 }
+ # hash # => {:a=>1, :b=>2 }
def slice!(*keys)
omit = slice(*self.keys - keys)
hash = slice(*keys)