Reputation: 1787
I have an array of hashes:
array = [
{
a: 1,
b: 2,
c: [3]
},
{
a: 1,
b: 2,
c: [3, 4, 5]
},
]
and would like to target the value 3
inside the array value for the c:
key in the first hash. I assume something would be added to array[0]
to capture that specific value.
Upvotes: 0
Views: 409
Reputation: 122493
In the Hash, c: [3]
is syntax sugar for :c => [3]
. So, to access the value 3
:
array[0][:c][0]
#=> 3
Upvotes: 4