Last active
January 5, 2020 13:53
-
-
Save lewisjkl/2fe7d3b190a01836d7ef82f17c093c40 to your computer and use it in GitHub Desktop.
Expressions using Future are often not referentially transparent.
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
val printStuff: Future[Unit] = Future(println("Hello, World!")) | |
for { | |
_ <- printStuff | |
_ <- printStuff | |
} yield () | |
// prints "Hello, World!" once | |
for { | |
_ <- Future(println("Hello, World!")) | |
_ <- Future(println("Hello, World!")) | |
} yield () | |
// prints "Hello, World!" twice |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment