Join the DZone community and get the full member experience.Join For Free
My ri docco says there is an Array#pad! but runtime Ruby says there isn't. Bah. So I wrote one:
class Array def pad!(expected_length, pad_item = nil) while expected_length > length self << pad_item end self end end
Opinions expressed by DZone contributors are their own.