a = [1,2]; b = [3]
a,b = [a, b].product([10]).map(&:flatten)
or
a,b = [a,b].zip(Array.new(2,10)).map(&:flatten)
or
a,b = [a,b].zip([10]*2).map(&:flatten)
# => a = [1, 2, 10],b = [3, 10]
This is obviously generalized to any number of arrays.
source
share