Sorry,I haven't been learning scala for long,i meet some question in 3.6.
def time[T](block: => T): T = {
val t0 = System.nanoTime()
val result = block
val t1 = System.nanoTime()
val timeMillis = (t1 - t0) / 1000000.0
println(s"Block took $timeMillis milliseconds!")
result
}
There's one thing I don't understand about the (block: => T),Why (block: => T) can appear here? I know this function has no parameters.But I still don't understand,sorry.If anyone can help me, I would be grateful!Thanks!
Sorry,I haven't been learning scala for long,i meet some question in 3.6.
There's one thing I don't understand about the (block: => T),Why (block: => T) can appear here? I know this function has no parameters.But I still don't understand,sorry.If anyone can help me, I would be grateful!Thanks!