Call ljust and rjust methods with an argument that is less than or equal to the length of the string : Justify Left « String « Ruby






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"

 

Related examples in the same category

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