Project

General

Profile

Actions

Feature #5552

closed

Array#ljust, Array#rjust

Added by sawa (Tsuyoshi Sawada) over 12 years ago. Updated over 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-dev:44778]

Description

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]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0