...

/

Splitting Strings

Splitting Strings

In the following lesson, you will learn how to split strings in Scala.

Problem

Imagine you have a list of items separated by a comma. You want to print the list vertically, item-by-item to make it easier to read. In other words, you want the compiler to split the string into separate lines at the commas.

Solution

In Scala, you can use the split method to split strings at specific separators such as commas. split converts a string into an ...