內部數組的第一個值我有查找基於第二值
@array = [
["Single - Tuesday - $13/meal", 1],
["Trifecta - Mon, Wed, Fri - $12/meal", 3],
["Quinary - Every weekday - $11/meal", 5]
]
如果我有內部數組的第二個值1
,3
,或5
,什麼是拉的第一個值的最簡單的方法是什麼?即,
some_method_or_whatever(1) # => "Single - Tuesday - $13/meal"
some_method_or_whatever(3) # => "Trifecta - Mon, Wed, Fri - $12/meal"
some_method_or_whatever(5) # => "Quinary - Every weekday - $11/meal"
爲什麼急於選擇答案? –