Last active
January 6, 2019 19:33
-
-
Save aaronoe/7c384d04d6eb2be3208acebafe10f52f to your computer and use it in GitHub Desktop.
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
| val myProperty by CounterProperty("foo") | |
| class CounterProperty(private val value: String) : ReadOnlyProperty<Any, String> { | |
| private var counter = 0 | |
| override fun getValue(thisRef: Any, property: KProperty<*>): String { | |
| return synchronized(counter) { | |
| println("Counter: ${++counter}") | |
| value | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment