Flowdock
method

extract!

Importance_1
v4.0.2 - Show latest stable - 1 note - 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}
{ a: 1, b: 2 }.extract!(:a, :x)             # => {:a=>1}
Show source
Register or log in to add new notes.
September 8, 2013
0 thanks

without a bang

We can use hash#slice if we want an Hash#extract (without bang) like behavior.