I am new to scala. I don't understand the compilation error for the below code:
def delayed( t:(Int)=> Int):Unit={
println("In delayed method")
var y=t;
println(y)
}
def time(x:Int):Int={
x*2
}
and when I call
delayed(time(8))
I get the following error:
scala> delayed(time(8))
<console>:15: error: type mismatch;
found : Int
required: Int => Int
delayed(time(8))
^
Please explain what is the issue? Please also suggest a good link to understand functions and function literals in scala. I am not able to understand fully.
Thanks so much
Edit:
Please tell the difference between
def delayed( t: Int => Int):Unit = {
and
def delayed(t: =>Int):Unit {
and
def delayed(t:=>Int):Unit { (without space b/w ":" and "=>"))