Home > Mobile >  How should I use lazy evalution in Classes in Scala?
How should I use lazy evalution in Classes in Scala?

Time:07-22

How should I use lazy evalution in Classes in Scala ?

I am new in Scala, learning from this site - https://www.geeksforgeeks.org/scala-lazy-evaluation/

I can not understand it fully, how should i use lazy datatype in class.

CodePudding user response:

try this code :

lazy val foo = {
  println("Initialized")
  1
}
foo: Int = <lazy>
  • Related