提交 9b6ee494 编写于 作者: C Charlie Somerville

don't map bang that

上级 f0fa43cf
......@@ -17,7 +17,7 @@ module Hash #:nodoc:
module Slice
# Returns a new hash with only the given keys.
def slice(*keys)
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
keys = keys.map { |key| convert_key(key) } if respond_to?(:convert_key, true)
hash = self.class.new
keys.each { |k| hash[k] = self[k] if has_key?(k) }
hash
......@@ -27,7 +27,7 @@ def slice(*keys)
# Returns a hash contained the removed key/value pairs
# {:a => 1, :b => 2, :c => 3, :d => 4}.slice!(:a, :b) # => {:c => 3, :d =>4}
def slice!(*keys)
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
keys = keys.map { |key| convert_key(key) } if respond_to?(:convert_key, true)
omit = slice(*(self.keys - keys))
hash = slice(*keys)
replace(hash)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册