object TestClass {
def main (args: Array[String]) {
println("Hello World");
val c = List (1,2,3,4,5,6,7,8,9,10)
println(findMax(c))
}
def findMax (tempratures: List[Int]) {
tempratures.foldLeft(Integer.MIN_VALUE) {Math.max}
}
}
Output shown is
Hello World
()
Why is the output not
Hello World
10
I’m doing this in IntelliJ
This is one of the most common scala typos.
You’re missing the
=at the end of your method:Should read:
Leaving the
=off means that your method returnsUnit(nothing).