Quick Padding your Ruby Array

ruby_arr = %w[0 1 2 3 ]
  #=> ["0", "1", "2", "3"]

rubyarr += (rubyarr.size < 10) ? ['abc'] * (10 - ruby_arr.size) : []
  #=> ["0", "1", "2", "3", "abc", "abc", "abc", "abc", "abc", "abc"]

Maricris Nonato

I turn tech ideas into websites using Ruby. I'm a budding Buddhist practitioner, passionate about health & fitness, and a cat fanatic!