0
我有一個名爲disciplines
低於這個哈希:如何將此散列轉換爲哈希數組?
disciplines = {"Architecture"=>"architecture", "Auditing"=>"auditing", "Consulting"=>"consulting", "Delivery"=>"delivery", "Development"=>"development", "Engineering"=>"engineering", "Environment/IT"=>"environment", "Graphic Design"=>"graphic_design", "Management"=>"management", "Requirements"=>"requirements", "Research"=>"research", "Support"=>"support", "System Design"=>"system_design", "Test & Eval"=>"test_and_evaluation", "Writing"=>"writing"}
而且我希望把它轉換成散列的數組,看起來像這樣:
[{"name"=>"Architecture", "value"=>"architecture"}, {"name"=>"Auditing", "value"=>"auditing"}, {"name"=>"Consulting", "value"=>"consulting"}, {"name"=>"Delivery", "value"=>"delivery"}, {"name"=>"Development", "value"=>"development"}, {"name"=>"Engineering", "value"=>"engineering"}, {"name"=>"Environment/IT", "value"=>"environment"}, {"name"=>"Graphic Design", "value"=>"graphic_design"}, {"name"=>"Management", "value"=>"management"}, {"name"=>"Requirements", "value"=>"requirements"}, {"name"=>"Research", "value"=>"research"}, {"name"=>"Support", "value"=>"support"}, {"name"=>"System Design", "value"=>"system_design"}, {"name"=>"Test & Eval", "value"=>"test_and_evaluation"}, {"name"=>"Writing", "value"=>"writing"}]
所以我只想把每一個鍵值對在第一哈希值,並將其映射到一個新的散列結果,其中現在的關鍵是name
值現在值是value
值,並把他們都在哈希