[Solved] Get value from Ruby hash


Hash is within an array so use this

p FIXED_COUNTRY_TO_PHONE.map{|x| x[:country]}

output

["FI", "SE"]

If you want to take the first country then

p FIXED_COUNTRY_TO_PHONE.first[:country]

If you want to take the last country then

p FIXED_COUNTRY_TO_PHONE.last[:country]

Getting the country code according to country

p FIXED_COUNTRY_TO_PHONE.detect{|x| x[:country].eql?'FI'}[:customer_phone]

12

solved Get value from Ruby hash