In Scala, you can use the split method to split strings at specific separators such as commas. split converts a string into an array of String elements and returns that array. For instance, if we have a string "a,b,c" and apply the split method on it, we would get an array of type String containing three elements: "a","b", and "c".
An array is a collection of elements of the same data type. For now, you can think of it as a variable that can store multiple values and each value has its own unique place. We will look at arrays in a later lesson in the course.
Let’s look at the syntax:
split takes one argument which lets the compiler know which separator it should split the string at. In our example, we are splitting at a comma, but you can choose any separator you want; "#", "*", etc.