mapOf<String, Any?>({"key" to "value"}) // Type mismatch
mapOf<String, Any?>(Pair("key", "value")) // fine
Can someone explain why?
mapOf<String, Any?>({"key" to "value"}) // Type mismatch
mapOf<String, Any?>(Pair("key", "value")) // fine
Can someone explain why?
{"key" to "value"}
is a lambda which receives 0 arguments and returns pair. You need to remove curly braces.