I have some code:
in_msg.updateComments.map{|c| c.values}.each do |comment|
...
end
where in_msg.updateComments is a hash. For some reason the first line if this snippet returns an error:
NoMethodError: undefined method `values' for #<Array:0x1382da058>
I am not sure why this happens. Any idea why it might happen and how to fix it?
The
mapmethod returns anEnumerator, which is going to loop over each key value pair in your hash, but it yields an array, not a hash, socwill look like[key, value]instead of{key => value}.Arraydoesn’t implementvalues, which is why you are getting the error.