groceries=[{"bread"=>"2", "eggs"=>"3", "cheese"=>"1", "butter"=>"4"},
{"juice"=>"3", "milk"=>"1", "tea"=>"1", "sugar"=>"1"}]
如何迭代每個散列並將其推入單獨的數組? 我想要的東西,看起來像這樣:通過ruby中的多維哈希進行迭代
items = [["bread","eggs","cheese","butter"],["juice","milk","tea","sugar"]]
如果我想保留格式但只返回長度大於五的元素,該怎麼辦? – olafsadventures
你的意思是,密鑰超過5個字符? –