this should work: ```inline fun <reified K, rei...
# announcements
a
this should work:
Copy code
inline fun <reified K, reified V> Any?.asLinkedMap(): LinkedHashMap<K, V>? {
    return (this as? Map<*, *>)
            ?.takeIf {
                it.entries.all { (key, value) -> key is K && value is V }
            }
            ?.map { (key, value) -> Pair(key as K, value as V) }
            ?.toMap(LinkedHashMap())
}
w
it.values.all { it != null }
is also needed.
And, maybe,
mapKaysTo
is not needed.
Oh without
mapKeysTo
, the type of the key is not String. I was wrong
a
true about values though 🙂 edited
w
good 😆 edited