When calling a function and passing over an argument which is an expression that needs to be evaluated, the expression will be evaluated before the function is invoked and its value will be passed over. This is the default behavior. By adding => in between the parameter name and its type we will defer the expression evaluation into the function execution and have it performed when its value is required.
package com.abelski object Program { def main(args: Array[String]) { println(System.currentTimeMillis()) printWithDelay(System.currentTimeMillis()) } def printWithDelay( t: => Long) = { Thread.sleep(10000) println(t) } }
The following video clips shows the execution of this code sample, overviews it and explains it.