DZone 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
Fill The Missing Blanks In An Array
If we have an array which has only 2 items yet we expected 4 items we can use Array#fill to complete it e.g.
r = %w(b c) # => ["b", "c"] r.fill('a', 2..3) # => ["b", "c", "a", "a"]
Resources: - <a href="http://ruby-doc.org/core/classes/Array.html#M002202">Class: Array</a> [ruby-doc.org]