Created
July 17, 2017 15:46
-
-
Save dimitarg/2309bfe044e85d4274f58030d8096026 to your computer and use it in GitHub Desktop.
This file contains 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
package demo | |
import fj.P | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty | |
class FjLazy<in R,T>(init: () -> T) : ReadOnlyProperty<R, T> { | |
val initIt = P.hardMemo(init) | |
override fun getValue(thisRef: R, property: KProperty<*>): T { | |
return initIt._1() | |
} | |
} | |
fun main(args: Array<String>) { | |
val foo: String by FjLazy { | |
println("initializing") | |
"asdasd" | |
} | |
println(foo) | |
println(foo) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment