삽질/Ruby

[Ruby] 빈 공간 텍스트 채우기

푸딩s 2014. 11. 28. 12:16


"hello".ljust(4)                  #=> "hello"

"hello".ljust(20)                #=> "hello               "

"hello".ljust(20, '1234')    #=> "hello123412341234123"


"hello".rjust(20, '1234')    #=> "123412341234123hello"