Created
March 31, 2019 16:40
-
-
Save breandan/8aecbca59419577981061617ed97dd03 to your computer and use it in GitHub Desktop.
Lazy properties, nullary functions, and custom getters oh my
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
object C { | |
inline fun longOp(): String { | |
val ms = System.currentTimeMillis() | |
while (true) if (System.currentTimeMillis() - ms > 30000) break | |
return "abc" | |
} | |
// val zoo = longOp() | |
val quick = "hello" | |
fun foo() = longOp() | |
val bar: () -> String | |
get() = { longOp() } | |
val baz = { longOp() } | |
val bat by lazy { longOp() } | |
// fun qux() = object { val longOp = C.longOp() } | |
} | |
println(C.baz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment