我有一个简单的数组将元组的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