Created
September 8, 2017 10:52
-
-
Save yoshihiro503/a283eec9e3e69506a70cf223b314bd5d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
case class Lazy[A](f: () => A) { | |
private var contents : Option[A] = None | |
def get() : A = { | |
this.contents match { | |
case None => | |
this.contents = f() | |
this.contents | |
case Some(x) => x | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment