A
ako...
hello,
i am still learning. in the below code @attributes is a hash table. i
want to add a new value 'a' for a key represented by 'a.key'. i also
want to group values with the same keys in to arrays. thanks for any
help.
konstantin
if @attributes.has_key?(a.key)
if @attributes[a.key].is_a?(Array)
@attributes[a.key] << a
else
@attributes[a.key] = [@attributes[a.key], a]
end
else
@attributes[a.key] = a
end
i am still learning. in the below code @attributes is a hash table. i
want to add a new value 'a' for a key represented by 'a.key'. i also
want to group values with the same keys in to arrays. thanks for any
help.
konstantin
if @attributes.has_key?(a.key)
if @attributes[a.key].is_a?(Array)
@attributes[a.key] << a
else
@attributes[a.key] = [@attributes[a.key], a]
end
else
@attributes[a.key] = a
end