Scala List Sum Method

Scala has a lot of pre-built methods. We are going to learn about one related to List called sum.

sum will go through each element of the List and add all the elements together.

It is actually a shortcut for list.fold(0)( _ + _ ). It might look strange syntax right now but SKB will help you become an expert soon.

Reveal more information and clues
Load Exercise