Question: RUBY! pigeon_data = { :color => { :purple => [Theo, Peter Jr., Lucky], :grey => [Theo, Peter Jr., Ms. K], :white => [Queenie, Andrew, Ms.

RUBY!
  1. pigeon_data = {
  2. :color => {
  3. :purple => ["Theo", "Peter Jr.", "Lucky"],
  4. :grey => ["Theo", "Peter Jr.", "Ms. K"],
  5. :white => ["Queenie", "Andrew", "Ms. K", "Alex"],
  6. :brown => ["Queenie", "Alex"]
  7. },
  8. :gender => {
  9. :male => ["Alex", "Theo", "Peter Jr.", "Andrew", "Lucky"],
  10. :female => ["Queenie", "Ms. K"]
  11. },
  12. :lives => {
  13. "Subway" => ["Theo", "Queenie"],
  14. "Central Park" => ["Alex", "Ms. K", "Lucky"],
  15. "Library" => ["Peter Jr."],
  16. "City Hall" => ["Andrew"]
  17. }
  18. }

The data above is organized by attributes - :color, :gender, and :lives, each a hash. Within these hashes are arrays of pigeon names.

We want this data, but in a different structure. Rather than sorting by attributes, your task is to create a hash where pigeon names are the keys, with each name pointing to a hash of their attributes.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!