method

extract!

v3.2.13 - Show latest stable - Class: Hash
extract!(*keys)
public

Removes and returns the key/value pairs matching the given keys.

{:a => 1, :b => 2, :c => 3, :d => 4}.extract!(:a, :b) # => {:a => 1, :b => 2}

1Note

without a bang

freemanoid321 ยท Sep 8, 2013

We can use hash#slice[http://api.rubyonrails.org/classes/Hash.html#method-i-slice] if we want an Hash#extract (without bang) like behavior.