slice!(*keys) public

Replaces the hash with only the given keys. Returns a hash containing the removed key/value pairs.

hash = { a: 1, b: 2, c: 3, d: 4 } hash.slice!(:a, :b) # => {:c=>3, :d=>4} hash # => {:a=>1, :b=>2}
Show source
Register or log in to add new notes.