
ru.tinkoff.phobos.derivation.CallByNeed.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of phobos-core_2.12 Show documentation
Show all versions of phobos-core_2.12 Show documentation
Fast xml data binding library
The newest version!
package ru.tinkoff.phobos.derivation
/*
* Copy-pasted from https://github.com/propensive/magnolia
*/
object CallByNeed { def apply[A](a: => A): CallByNeed[A] = new CallByNeed(() => a) }
final class CallByNeed[+A](private[this] var eval: () => A) extends Serializable {
lazy val value: A = {
val result = eval()
eval = null
result
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy