After updating to Kotlin 1.4, I get a couple of ty...
# getting-started
m
After updating to Kotlin 1.4, I get a couple of type inference issues regarding
emptyList()
for example:
Copy code
val retrievedList = myMap[someKey] ?: emptyList()
now gives a compiler warning (though the IDE doesn’t complain) when trying to access items in
retrievedList
so I need to explicitly set
List<MyListItemType>
as the
retrievedList
type or the
emptyList()
generic. I can’t seem to reproduce this in the kotlin playground, so can only assume there is some inconsistency caused by my gradle build scripts or some build caching issue.
e
no idea what you're running into but
Copy code
val retrievedList = myMap[someKey].orEmpty()
could work, right?
👍 1