Skip to content

Instantly share code, notes, and snippets.

@yoshihiro503
Created September 8, 2017 10:52
Show Gist options
  • Save yoshihiro503/a283eec9e3e69506a70cf223b314bd5d to your computer and use it in GitHub Desktop.
Save yoshihiro503/a283eec9e3e69506a70cf223b314bd5d to your computer and use it in GitHub Desktop.
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