Home
Ruby
ActiveRecord
Array
CGI
Class
Collections
Database
Date
Design Patterns
Development
File Directory
GUI
Hash
Language Basics
Method
Network
Number
Rails
Range
Reflection
Statement
String
Threads
Time
Tk
Unit Test
Windows Platform
XML
Add to both sides : Justify Right « String « Ruby
Ruby
String
Justify Right
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