Fill The Missing Blanks In An Array
Join the DZone community and get the full member experience.Join For Free
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: - Class: Array [ruby-doc.org]
Blank (solution) Data structure
Opinions expressed by DZone contributors are their own.