Is there any easier way in Kotlin to achieve that ...
# announcements
f
Is there any easier way in Kotlin to achieve that mapping to state variables without repeating myself over and over again? Can I make my State attributes somehow directly accessible in main Class?
s
Is state a class or interface?
a
Well if there's an interface with only the id then you could use delegate by
or I mean an interface with the attributes you want to expose
s
If you define the properties of
State
in some interface, then you could declare it like
Copy code
class Blub(state: State): State by state
f
Since it’s about 30 attributes, I guess delegate by will get too much boilercode. Introducing an interface would be easier, let me give a try. Thank you guys !
b
what about storing the properties in a map and delegating to that? https://kotlinlang.org/docs/reference/delegated-properties.html#storing-properties-in-a-map
if
State
could implement Map, maybe