我有這個工作與複雜的陣列:如何訪問哈希
[
["app1", {"name"=>"name1", "path"=>"xyz.com/"}],
["app2", {"name"=>"name2", "path"=>"xyz.com/"}],
["app3", {"name"=>"name3", "path"=>"xyz.com/"}],
# etc.
]
我希望能夠訪問每個名稱和路徑,所以我嘗試:
apps.each do |key, value|
value.each do |key, value|
puts value
end
end
但這返回枚舉。任何想法我怎麼能做到這一點?
考慮爲這種事情創建自己的'類' - 更具可讀性。 – Reactormonk 2012-03-22 15:35:36