Hashes Within Hashes : Nested hash « Hash « Ruby






Hashes Within Hashes

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

    'age' => 55,
    'gender' => 'female'
  }
}

puts people['fred']['age']
puts people['janet']['gender']
puts people['janet'].inspect

 








Related examples in the same category

1.Access array embedded within a hash