Skip to content

Instantly share code, notes, and snippets.

@harmeetsingh0013
Created July 7, 2018 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harmeetsingh0013/1a8d8e114490d27f2f08f34f8fce9c29 to your computer and use it in GitHub Desktop.
Save harmeetsingh0013/1a8d8e114490d27f2f08f34f8fce9c29 to your computer and use it in GitHub Desktop.
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