Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.language.implicitConversions
- object Lazy {
- class Lazy[T](r: => T) extends Function0[T] {
- lazy val result = r
- def apply(): T = {
- result
- }
- // This doesn't work...
- // def `match`[R](body: T => R):R = {result match body}
- }
- implicit def unbox[T](box: Lazy[T]): T = box()
- def apply[T](r: => T) = new Lazy(r)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement