Loop over multiple arrays simultaneously

The simplest way is by using the Array.zip() method:

[%w(a b c),%w(A B C),%w(1 2 3)].zip { |i,j,k|
    say (i, j, k)
}

Output:

aA1
bB2
cC3

Last updated