The by
keyword sets up a "delegate": an object that will serve as an intermediary
for your property.
Map
works as a property delegate for val
properties. You can use
by
to set up a Map
as a property delegate for some property, as we
have done here for something
and somethingElse
.
This might be useful in cases where other code is giving you the Map
(e.g., some data parser) and you want to have more natural Kotlin code
for accessing the data.
You can learn more about this in:
Tags: