Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Dr Nic Williams http://drnicwilliams.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Array#pad!

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
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS