https://kotlinlang.org logo
#getting-started
Title
# getting-started
r

reactormonk

09/20/2023, 5:24 PM
Is there a shortcut for
Copy code
var repeatMode: @Player.RepeatMode Int
        get() {
            return player.repeatMode
        }
        set(value) {
            player.repeatMode = value
        }
g

Gleb Minaev

09/20/2023, 5:41 PM
What about this?
Copy code
var repeatMode2: @Player.RepeatMode Int by player::repeatMode
💯 1
2
🤯 1
r

reactormonk

09/20/2023, 5:41 PM
Neato
s

Stephan Schröder

09/20/2023, 10:08 PM
so tear-offs are instances of 'Delegate'!? Or just made into one if necessary? Or can 'by' handle Delegates and tear-offs?
g

Gleb Minaev

09/21/2023, 8:27 AM
It looks like kotlin compiler handles such cases. I wrote a simple example and it was optimised to good old getter and setter invokations (on JVM at least):
K 2