Why do delegate class methods `getValue` and `setValue` need to marked with `operator` keyword?
a
Why do delegate class methods
getValue
and
setValue
need to marked with
operator
keyword?
h
to be accessed like:
Copy code
val message: String by delegate
a
I thought so! But I donโ€™t see anywhere in the doc that
by
is an operator, just a soft keyword
h
yeah ๐Ÿค” actually
by
can be used on simple classes too https://kotlinlang.org/docs/delegation.html
a
Yeah your link mentions
by
as clause not an operator, right?
๐Ÿ‘ 1
h
image.png
and in observable delegate, setValue and getValue are not operators
so, idk ๐Ÿ˜„
๐Ÿ‘ 1
a
Actually
ReadWriteProperty
which
ObservableProperty
inherits from defines them as `operator`s ๐Ÿ™‚
h
yeah, that's true blob thinking upside down
a
Iโ€™ve created a StackOverflow question just in case.
@henrikhorbovyi someone answered the question perfectly on SO. You might want to check it out.
h
ooh... cool
a
by is an operator. It operates on getValue and setValue. If the docs is missing that, then its something that has to be added