Created
September 22, 2012 23:11
-
-
Save klgraham/3768172 to your computer and use it in GitHub Desktop.
Advantage of occasional call-by-name
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 loop: Int = loop // this is allowed | |
def first(a: Int, b: Int): Int = a | |
def first1(a: Int, b: => Int): Int = a | |
first(3 + 4, loop) // this will fail | |
first1(3 + 4, loop) // this will return 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment