Say, first, I have this function:
def number5()={
println("number 5 starting")
println("number 5 exiting")
5
}
And then:
def giveMeCallByNameParameter(f: =>Int)={
println("starting")
f
println("exiting")
}
When I call it:
giveMeCallByNameParameter(number5)
I get this result:
starting
number 5 starting
number 5 exiting
exiting
And if I also have this function:
def giveMeAnotherFunction(f: ()=>Int)={
println("starting")
f()
println("exiting")
}
And I call it:
giveMeAnotherFunction(number5)
I get the same result:
starting
number 5 starting
number 5 exiting
exiting
So, are they different at all? Other than the difference of having or not having the parenthesis?
If they are not different? Then why do we have this terminology call by name?