我有两个数组
arr1 = ["a","b","c","d"]
arr2 = ["e","f","g","h"]
我希望得到像这样的结果
arr3 = ["ae","bf","cg","dh"]
我怎么能在红宝石中做到这一点?
答案 0 :(得分:2)
我使用#zip
:
arr1 = ["a","b","c","d"]
arr2 = ["e","f","g","h"]
arr1.zip(arr2).map(&:join)
# => ["ae", "bf", "cg", "dh"]