Created
December 17, 2021 23:55
-
-
Save awesome/a8eb6676768969b94457acfd087d8e02 to your computer and use it in GitHub Desktop.
Pad An Array To Be A Certain Size in Ruby
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
# https://stackoverflow.com/questions/5608918/pad-an-array-to-be-a-certain-size#16180695 | |
def rpad(item, padding, num) | |
Array(item).fill padding, Array(item).size, num | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment