Rich operations performed on collections
We have quite a few methods for our collections, which we can use to simplify almost every problem regarding collections in Scala. We are going to take a look at some important methods. First, let's set the stage: so consider a scenario where you have some structured data related to football players. and you have to perform manipulations based on that. We'll perform a set of operations on the data using our collection. We'll also learn about methods, their signatures, and use cases along the way. Here's a simple code snippet that shows what we just said—nothing too interesting as of now:
package chapter5 object CollectionOperations extends App { val source = io.Source.fromFile("../src/chapter5/football_stats.csv") // Give pathString for the csv file }
Here's the thing—we have a CSV file that contains some data as comma-separated values. We can read the data in our program as a BufferredSource
:
io.Source.fromFile("filePath")
This will load...