Add to both sides : Justify Right « String « Ruby






Add to both sides


title = "Love's Labours Lost"
title.rjust(20, "-").ljust(21, "-")

 








Related examples in the same category

1.Use another character besides the default space character if you'd like
2.Use more than one character the sequence will be repeated
3.Justify at both sides