i'm trying to put a `java.lang.Object` in a map wi...
# getting-started
t
i'm trying to put a
java.lang.Object
in a map with type
Map<Class<*>, Any>
, i'm getting the following error message that i'm not able to figure out:
Copy code
Required type: capture of ? extends Object
Provided: Object
d
Map
in Kotlin is
Map<K, out V>
because
Map
is read only. If you intend to mutate it you should declare it as
MutableMap
t
of course
haha
ctrl+alt+shift+k is dangerous
thank you 😄
i still don't understand the error message though
d
Map<Class<*>, Any>
=
Map<Class<*>, out Any>
=
Map<Class<?>, ? extends Object>
And that means "I don't know what the values are, but they extend
Object
. That effectively means "I can't put anything in here, because I don't know what goes there"
"capture of ? extends Object" means "whatever type would go there" basically. And "Object" is not it