我有一個簡單的數組將元組的Ruby元組轉換爲散列給定的一組鍵?
array = ["apple", "orange", "lemon"]
array2 = [["apple", "good taste", "red"], ["orange", "bad taste", "orange"], ["lemon" , "no taste", "yellow"]]
我怎樣才能轉換到該散列每當在數組元素中數組2的每個元件的第一元件相匹配?
hash = {"apple" => ["apple" ,"good taste", "red"],
"orange" => ["orange", "bad taste", "orange"],
"lemon" => ["lemon" , "no taste", "yellow"] }
我對紅寶石頗爲陌生,花了很多錢做這個操作,但沒有運氣,有什麼幫助?
那你究竟是「符合每個元素的數組2的第一個元素」是什麼意思? – Mischa
不要編輯我的答案,發表評論 – Mischa