Call by Value, Name, Need
Exercise 1
- Make it a
call by name - Make it a
call by needby adding alazy val
def exercise(str: String) =
Thread.sleep(2000)
println(s"first: $str at ${System.nanoTime()}")
Thread.sleep(2000)
println(s"second: $str at ${System.nanoTime()}")
exercise("hello")
Exercise 2
Create a function def currentTime(time: Long)
- Make it a
call by value - Make it a
call by name - Make it a
call by needby adding alazy val