mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Use map, no need to use inject here.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
committed by
Santiago Pastorino
parent
7047d83ec5
commit
c88deaf5ee
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user