Method: Hash#delete_values_at
- Defined in:
- lib/core/facets/hash/delete_values.rb
#delete_values_at(*keys, &yld) ⇒ Object
Minor modification to Ruby’s Hash#delete method allowing it to take multiple keys.
hsh = {:a=>1, :b=>2, :c=>3}
a, b, c = hsh.delete_values_at(:a, :b, :c)
[a, b, c] #=> [1, 2, 3]
hsh #=> {}
CREDIT: Daniel Schierbeck
37 38 39 |
# File 'lib/core/facets/hash/delete_values.rb', line 37 def delete_values_at(*keys, &yld) keys.map{|key| delete(key, &yld) } end |