Exercise 2: Padding and Justifying
Explore Ruby's string manipulation by learning to use padding and justifying methods. Understand how to align text with custom padding strings and apply these techniques to format tables or improve text presentation.
We'll cover the following...
We'll cover the following...
Problem statement
There’s a method that allows us to justify a string by
Look for that method by skimming through the Ruby documentation for strings. Use it on the input string to accomplish the same task as before.
Example
input_string = "ruby"
result = "ruby<3<3<3"
Note: This is a rather unorthodox usage of this method. Normally, we’d use it to align strings to columns so that they line up nicely when we format a table. You’ll use it in exercises later in the course to do just that!