说我有以下两个数组
array_1 = ["Person One", "Person Two", "Person Three"]
array_2 = ["24", "25", "26"]
如何将这些数组合并在一起,以便输出
["Person One 24", "Person Two 25", "Person Three 26"]
由于
答案 0 :(得分:3)
答案 1 :(得分:1)
您可以按照以下方式执行此操作:
array_1.each_with_index.map{ |el, i| el + " " + array_2[i].to_s }
# => ["Person One 24", "Person Two 25", "person Three 26"]
答案 2 :(得分:1)
src dest relationship
CK200 CK201 CK200-CK201
CK201 CK200 CK201-CK200
KY305 KY306 KY305-KY306
KY306 KY305 KY306-KY305
LM102 LM103 LM102-LM103
LM103 LM102 LM103-LM102