Skip to content

Instantly share code, notes, and snippets.

@3limin4t0r
Last active March 19, 2021 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3limin4t0r/26d855bbb78cc3f85050172f7a92884f to your computer and use it in GitHub Desktop.
Save 3limin4t0r/26d855bbb78cc3f85050172f7a92884f to your computer and use it in GitHub Desktop.
# mutating
def equalize_size!(*arrays)
max_size = arrays.map(&:size).max
arrays.each { |array| array[max_size, 0] = [] }
end
# non-mutating
def equalize_size(*arrays)
equalize_size!(*arrays.map(&:dup))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment