In this section, we are going to walk through how to use the split, strip, join methods in Ruby. These methods will help us clean up strings and convert a string to an array so we can access each word as its own value.
Split, strip, and join guides for strings
Using the strip method
Let's start off by analyzing the strip method. Imagine that the input you get from the user or from the database is poorly formatted and contains white spaces before and after the value. To clean the data up, we can use the strip method. Consider this example:
str = " The quick brown fox jumped over the quick dog "
p str.strip
When you run this code, the output is just the sentence without the white spaces before and after the...