Access array embedded within a hash : Nested hash « Hash « Ruby






Access array embedded within a hash


people = {
  'fred' => {
    'name' => 'F',
    'age' => 63,
    'gender' => 'male',
    'favorite painters' => ['A', 'B', 'C']
  },
  'janet' => {
    'name' => 'J',
    'age' => 55,
    'gender' => 'female'
  }
}


puts people['fred']['favorite painters'].length
puts people['fred']['favorite painters'].join(", ")

 








Related examples in the same category

1.Hashes Within Hashes