CLOVIS
12/13/2020, 6:03 PMinterface Attributes<T>
enum class StringAttributes : Attributes<T> { ... }
val attributes: Map<Attributes<Any>, Any>
val others: Map<StringAttributes, String> = ...
However, if I write:
attributes = others
I get a Type Mismatch
.
I guess the solution has something to do with properly using in and out, however I don't understand what the correct way to use those is.CLOVIS
12/13/2020, 6:23 PMinterface Attributes<out T>
val attributes: Map<out Attributes<Any>, Any>
However, I'm not completely sure I understand why that works, even after reading the documentation...streetsofboston
12/13/2020, 7:41 PMB
is a sub-type of A
, then you can safely assign a variable of type B
to a variable of type `A`:
val aB: B = ....
val anA: A = B
.