From 308595739c32609ac5b167ecdc6cb6cb4ec6c81f Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Mon, 15 Aug 2011 20:20:28 -0300 Subject: Document Hash#extract!. --- activesupport/lib/active_support/core_ext/hash/slice.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/lib/active_support/core_ext/hash/slice.rb') diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb index d7fb2da0fb..0484d8e5d8 100644 --- a/activesupport/lib/active_support/core_ext/hash/slice.rb +++ b/activesupport/lib/active_support/core_ext/hash/slice.rb @@ -30,6 +30,8 @@ class Hash omit end + # 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} def extract!(*keys) result = {} keys.each {|key| result[key] = delete(key) } -- cgit v1.2.3