I wrote this is Scala Repl
def sum(a: Int, b: Int) = a + b
This is evaluated as
sum: (a: Int, b: Int)Int in Repl. def in Scala is lazily evaluated. So, what is the type that Repl displays? Also, how is this eagerly evaluated when sum(1,2) is called or how is (a: Int, b: Int)Int evaluated to Int?
I noticed this when I was playing with val in Scala. If I write val sum = (a: Int, b: Int) = a + b this is eagerly evaluated into (Int, Int) => Int = <function2> which is fine as the apply function call is made. But I don't understand what happens in case of def.