Programming Kotlin - Sample code not compiling in postcomment.kts file (page 166)

Hi @venkats,

Unfortunately with Kotlin 1.4 following compiler error is shown for the following code in postcomment.kts

val forPost1 = PostComment(data[0])
val forPost2 = PostComment(data[1])

Error:
Type mismatch.
Required: MutableMap<String, Any>
Found: MutableMap<String, out Any>

Imho the error must be correct but is this a “typo” or is it because i use Kotlin version 1.4. If the latter is the case, do you maybe know what changed from version 1.3 to 1.4 so that now the compiler “smarter”?

Thank you.

Hi @Sageniuz

Thank you for mentioning this.

Modifying

val data = listOf(

to

val data: List<MutableMap<String, Any>> = listOf(

fixed the issue.

Regards,

Venkat