jishindev
07/01/2019, 11:44 AMfun String.()
for each lamda inside this map creation? mapOf<String, String.() -> Unit>(
"One" to fun String.(){ println(this) }
)
It gives Type inference failed. Expected type mismatch: inferred type is Pair<String, () -> Unit> but Pair<String, String.() -> Unit> was expected
if I don't use the fun String.()
while defining the lambda.Shawn
07/01/2019, 12:15 PM{ str: String -> println(str)
, and that’d pass just fine as a String.() -> Unit
, but to use this
I don’t think you can avoid having to use the anonymous fun
syntaxmapOf(
"One" to fun String.() = println(this)
)
jishindev
07/01/2019, 12:28 PM