Created
July 7, 2018 11:56
-
-
Save harmeetsingh0013/1a8d8e114490d27f2f08f34f8fce9c29 to your computer and use it in GitHub Desktop.
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
object EvalExample2 extends App { | |
def twice(value: Int): Int = value * value | |
def divideBy2(value: Int): Int = value / 2 | |
val value = 42 | |
val intermediateResult = twice(value) | |
val result = divideBy2(intermediateResult) | |
println(result) | |
val result1 = Eval.now(42).map(twice).map(divideBy2) | |
println(result1) | |
println("Demand The Eval Results") | |
println(result1.value) | |
} | |
/* OUTPUT | |
Without Eval Result: 882 | |
Eval Declared only: cats.Eval$$anon$6@39fb3ab6 | |
Demand The Eval Results | |
With Eval Result: 882 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment