I think I can help on this one! It's lambda stuff. Passing a function around like a variable. I'm not an expert, especially w.r.t terminology. But I hope I can help.
There's some function currying going on there as well, I believe, so you'll want to look up that I think, but the things confusing you were not directly related to that I think.
For your specific questions, I believe the following example might be helpful. The code below wraps try/catch statements so I don't have to have try/catch in every method. I simply put it in 1 method, that accepts a function as a parameter.
def resume():Unit = {
return wrapTryCatchUnit(()=>server.resume())
}
private def wrapTryCatchUnit(lambdaFunc:() => Unit): Unit = {
try {
lambdaFunc()
} catch Utilities.safely {
case ex: Throwable => {
ex.printStackTrace()
throw ex
}
}
}
Consider the following
def function(myvar: Int) = myvar + 1
Now consider calling this:
function(10)
The resume method below calls wrapTryCatchUnit passing it:
()=>server.resume()
This is equivalent to function(10), where ()=> server.resume() is a lambda function passed to wraptrycatchunit.
Now consider:
private def wrapTryCatchUnit(lambdaFunc:() => Unit)
The lambdaFunc:() => Unit is how you declare the lambda signature. It's equivalent to myvar: Int in function(myvar: Int).
Finally to execute the function you do:
lambdaFunc() as is done in the try statement below.
Hope this helps!