合并2数组到相同的索引值 [英] Merge 2 arrays into same index value
本文介绍了合并2数组到相同的索引值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说我有以下两个阵列
array_1 = ["Person One", "Person Two", "Person Three"]
array_2 = ["24", "25", "26"]
我怎么会这些数组合并到一起,使输出将
How would I merge these arrays together so that the output would be
["Person One 24", "Person Two 25", "Person Three 26"]
感谢
推荐答案
array_1.zip(array_2).map { |a| a.join(' ') }
这篇关于合并2数组到相同的索引值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文