aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lopez 👾 <daniel@6temes.cat>2018-11-21 08:11:07 +0900
committerDaniel Lopez 👾 <daniel@6temes.cat>2018-11-21 08:11:07 +0900
commit4fa6a5c4e02bf6c511ecda9db4fd61e51634fe06 (patch)
treee4dea1f7fb32145a9008756597519b0c4c3afdcf
parent218e50ce59c3abfa5ffdfac253cdeb2f74602da0 (diff)
downloadrails-4fa6a5c4e02bf6c511ecda9db4fd61e51634fe06.tar.gz
rails-4fa6a5c4e02bf6c511ecda9db4fd61e51634fe06.tar.bz2
rails-4fa6a5c4e02bf6c511ecda9db4fd61e51634fe06.zip
Improve documentation for Hash#slice!
-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)