Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (17 sloc) 538 Bytes
package scalaBasics.absoluteBasics
object CBNvsCBV extends App {
def calledByValue(x: Long): Unit = {
println("by value: " + x)
println("by value: " + x)
}
def calledByName(x: => Long): Unit = {
println("by name: " + x)
println("by name: " + x)
}
calledByValue(System.nanoTime())
calledByName(System.nanoTime())
def infinite(): Int = 1 + infinite()
def printFirst(x: Int, y: => Int) = println(x)
// printFirst(infinite(), 43) - will crash with a stack overflow error
printFirst(43, infinite())
}
You can’t perform that action at this time.