mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
15 lines
584 B
Plaintext
15 lines
584 B
Plaintext
Returns a copy of +self+, left-justified and, if necessary, right-padded with the +pad_string+:
|
|
|
|
'hello'.ljust(10) # => "hello "
|
|
' hello'.ljust(10) # => " hello "
|
|
'hello'.ljust(10, 'ab') # => "helloababa"
|
|
'тест'.ljust(10) # => "тест "
|
|
'こんにちは'.ljust(10) # => "こんにちは "
|
|
|
|
If <tt>width <= self.length</tt>, returns a copy of +self+:
|
|
|
|
'hello'.ljust(5) # => "hello"
|
|
'hello'.ljust(1) # => "hello" # Does not truncate to width.
|
|
|
|
Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
|