I wanted to have a property that counts how many t...
# announcements
a
I wanted to have a property that counts how many times it's been accessed, so I tried:
Copy code
val countGets: Int = 0
        get() = ++field
And I got the warning
Reassignment of read-only property via backing field is deprecated
But I couldn't find anything about this in Google, so what's the recommended way to get the same effect?