Skip to content

Instantly share code, notes, and snippets.

@vumanhcuongit
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save vumanhcuongit/321c758b4aeb3488a534 to your computer and use it in GitHub Desktop.

Select an option

Save vumanhcuongit/321c758b4aeb3488a534 to your computer and use it in GitHub Desktop.
Interleave Array
def interleave(a, b)
return [a, b].transpose.flatten if a.size == b.size
if a.size > b.size
b << nil
else
a << nil
end
[a, b].transpose.flatten.compact
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment