The .split method is a built-in method; it takes in a string and returns an array.
If we pass it a bit of text in parentheses, .split will divide the string wherever it sees that bit of text.
For example:
text. split(",")
This code tells Ruby to split up the string text wherever it sees a comma.
For example:
text = "cat chased the mouse"
text.split(" ")
output: ["cat", "chased", "the", "mouse"]
Top comments (0)