Kotlin supports this: ``` public fun <K: An...
# getting-started
a
Kotlin supports this:
Copy code
public fun <K: Any, V: Any> Map<K,V>.toFunc(): (K)->V? {
        return fun (key: K): V? { return this[key] }
    }
    
    public fun foo() {
        val myMap = mapOf("this" to "that")
        val func = myMap.toFunc()
        func("this")  // returns "that"
    }
then just
myMap.toFunc()
and use your function