我有两个 Ruby 数组days
and trips
,以及如下所示的星期几:
days = ["Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday","Sunday"]
以及这里的巴士时刻表:
trips = [
"2.35pm","4.50pm","7.00pm",
"2.35pm","4.50pm","7.00pm",
"2.35pm","4.50pm","7.00pm",
"2.35pm","4.50pm","7.00pm",
"2.35pm","4.50pm","7.00pm",
"2.35pm","4.50pm","7.00pm",
"2.35pm","4.50pm","7.00pm"
]
我试图达到的结果是这样的:
Bus-times = [
"Monday","2.35pm","4.50pm","7.00pm",
"Tuesday","2.35pm","4.50pm","7.00pm",
"Wednesday","2.35pm","4.50pm","7.00pm",
"Thusday","2.35pm","4.50pm","7.00pm",
"Friday","2.35pm","4.50pm","7.00pm",
"Saturday","2.35pm","4.50pm","7.00pm",
"Sunday""2.35pm","4.50pm","7.00pm"
]
我看过交错,zip
如果我不编写自己的函数,则只返回第一个结果。我还有什么其他选择?