Ruby/String/Justify Left

Материал из Wiki.crossplatform.ru

Версия от 17:56, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Call ljust and rjust methods with an argument that is less than or equal to the length of the string

title = "AAA"
title.ljust 10 # => "AAA"
title.rjust 19 # => "AAA"



The added whitespace is calculated based on the length of the string plus the value of the argument.

title = "AAA"
puts title.ljust 20 
puts title.rjust 25