提交 e167389e 编写于 作者: E Erik Michaels-Ober

Don't construct a Proc if no block is given

上级 073397cf
......@@ -4,7 +4,7 @@ class Hash
#
# { a: 1, b: 2, c: 3 }.transform_values { |x| x * 2 }
# # => { a: 2, b: 4, c: 6 }
def transform_values(&block)
def transform_values
result = self.class.new
each do |key, value|
result[key] = yield(value)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册