Method: Array#pad

Defined in:
lib/rext/array/helpers.rb

#pad(n, pad_with = nil) ⇒ Object

Pad array with expected length n, and pad_with an optional object or nil.

Examples

[1,2].pad(4)  # => [1,2,nil,nil]
[1,2].pad(4)  # => [1,2,'x','x']
[1,2].pad(2)  # => [1,2]


47
48
49
# File 'lib/rext/array/helpers.rb', line 47

def pad n, pad_with = nil
  fill pad_with, length, n - length
end