diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-11-20 18:22:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-20 18:22:00 -0500 |
commit | 9fb53e7b198a0b497566f06ba938d66502fa4326 (patch) | |
tree | ee5114054f98ed3d3fd912ec0b8561e1020b2ee1 /activesupport/lib | |
parent | 4800fd072f2a8349e92cf9386da4b66de712a669 (diff) | |
parent | 4fa6a5c4e02bf6c511ecda9db4fd61e51634fe06 (diff) | |
download | rails-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/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/slice.rb | 5 |
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) |