From: Thomas Sawyer Date: 2011-11-06T17:02:44+09:00 Subject: [ruby-dev:44806] [ruby-trunk - Feature #5552] Array#ljust, Array#rjust Issue #5552 has been updated by Thomas Sawyer. If you know pad length is greater than the array length then: [:a,:b,:c].insert(5, nil) Not sure about "rjust" though. I suppose there is always: a.unshift(nil) until a.size == 5 Though that seems fairly inefficient. ---------------------------------------- Feature #5552: Array#ljust, Array#rjust http://redmine.ruby-lang.org/issues/5552 Author: Tsuyoshi Sawada Status: Feedback Priority: Normal Assignee: Category: Target version: I propose the following methods Array#ljust(length [, pad]), Array#rjust(length [, pad]), whose behaviour is analogous to String#ljust(length [, padstr]), String#rjust(length [, padstr]). [:a, :b, :c].ljust(2) #=> [:a, :b, :c] [:a, :b, :c].ljust(5) #=> [:a, :b, :c, nil, nil] [:a, :b, :c].ljust(5, :x) #=> [:a, :b, :c, :x, :x] -- http://redmine.ruby-lang.org