Because you define findMax without a return type, so the return type is Unit or () .
def findMax (tempratures: List[Int]) { ... }
aka
def findMax (tempratures: List[Int]) : Unit = { ... }
Instead you want
def findMax (tempratures: List[Int]) : Int = { ... }
or omitted type
def findMax (tempratures: List[Int]) = { ... }
source share