-
-
Save 3limin4t0r/26d855bbb78cc3f85050172f7a92884f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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