Skip to content

Instantly share code, notes, and snippets.

@jwalgemoed jwalgemoed/delegate.kt Secret
Last active Jan 3, 2018

Embed
What would you like to do?
val fileContents by FileLoaderDelegate("someFile.txt")
class FileLoaderDelegate(private val filename: String) {
operator fun getValue(thisRef: Any?, property: KProperty<*>): Any {
return readFile(filename)
}
}
fun main(args: Array<String>) {
println(fileContents)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.