Array.pad
padnelem
Group: Calculations
Documentation
Extend self
array to the length of n
appending elements elem
to the end.
If the new length n
is less than existing length, self
array is returned.
Arguments
n
: The length to padself
out to.elem
: The element to fill the new padded slots with.
Examples
Extending array to the length of 5
[1, 2, 3].to_array.pad 5 0 == [1, 2, 3, 0, 0].to_array
Extending array to the length of 5
[1, 2, 3, 4, 5].to_array.pad 5 0 == [1, 2, 3, 4, 5].to_array