Created
May 12, 2018 11:37
-
-
Save pavel-filatov/f984515ca29e652b8043dc14a023269f to your computer and use it in GitHub Desktop.
Scala Evaluation Rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def example = 2 // evaluated when called | |
val example = 2 // evaluated immediately | |
lazy val example = 2 // evaluated once when needed | |
def square(x: Double) // call by value | |
def square(x: => Double) // call by name | |
def myFct(bindings: Int*) = { ... } // bindings is a sequence of int, containing a varying # of arguments |
Author
pavel-filatov
commented
May 12, 2018
- Call by value: evaluates the function arguments before calling the function
- Call by name: evaluates the function first, and then evaluates the arguments if need be
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment