提交 c88deaf5 编写于 作者: E Emilio Tagua 提交者: Santiago Pastorino

Use map, no need to use inject here.

Signed-off-by: NSantiago Pastorino <santiago@wyeworks.com>
上级 7047d83e
......@@ -10,10 +10,7 @@ class Object
#
# C.new(0, 1).instance_values # => {"x" => 0, "y" => 1}
def instance_values #:nodoc:
instance_variables.inject({}) do |values, name|
values[name.to_s[1..-1]] = instance_variable_get(name)
values
end
Hash[instance_variables.map { |name| [name.to_s[1..-1], instance_variable_get(name)] }]
end
# Returns an array of instance variable names including "@". They are strings
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册