Skip to content

Instantly share code, notes, and snippets.

Created July 7, 2018 11:44
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
object EvalExample1 extends App {
val eager = {
println("Hey !! I am eager eval")
"Hello Eval Eager"
val lazyEval = Eval.later {
println("Hey !! I am lazy eval")
"Hello Eval Lazy"
val always = Eval.always {
println("Hey !! I am always eval")
"Hello Eval Always"
println(s"Eval Eager: ${eager}")
println(s"Eval Eager 1: ${eager.value}")
println(s"Eval Eager 2: ${eager.value}")
println(s"Eval Lazy: ${lazyEval}")
println(s"Eval Lazy 1: ${lazyEval.value}")
println(s"Eval Lazy 2: ${lazyEval.value}")
println(s"Eval Always: ${always}")
println(s"Eval Always 1: ${always.value}")
println(s"Eval Always 2: ${always.value}")
Hey !! I am eager eval
Eval Eager: Now(Hello Eval Eager)
Eval Eager 1: Hello Eval Eager
Eval Eager 2: Hello Eval Eager
Eval Lazy: cats.Later@61a485d2
Hey !! I am lazy eval
Eval Lazy 1: Hello Eval Lazy
Eval Lazy 2: Hello Eval Lazy
Eval Always: cats.Always@39fb3ab6
Hey !! I am always eval
Eval Always 1: Hello Eval Always
Hey !! I am always eval
Eval Always 2: Hello Eval Always
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment