Chris Ledet Chris Ledet - 2 years ago 133
Ruby Question

Merge and interleave two arrays in Ruby

I have the following code:

a = ["Cat", "Dog", "Mouse"]
s = ["and", "&"]

I want to merge the array
into array
which would give me:

["Cat", "and", "Dog", "&", "Mouse"]

Looking through the Ruby Array and Enumerable docs, I don't see such a method that will accomplish this.

Is there a way I can do this without iterating through each array?

Answer Source

You can do that with:
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download