...

/

Solution Review: Sum of Lists

Solution Review: Sum of Lists

In the following lesson, we will go over the solution of the challenge: Sum of Lists.

Task

In this challenge, you had to create a recursive function sum which sums together all the integers in a List.

Solution

A skeleton of the function was already provided for you. Let’s look it over.

def sum(numberList: List[Int]): Int = numberList match { 

}

sum takes a single parameter of type List[Int] and returns a value of type Int.

The function body of sum consists of a match expression. You needed to write the ...