LS
01/31/2020, 6:21 PMfun <K, V> MutableMap<Set<K>, V>.put2(vararg keys: K, value: V) = put(keys.toSet(), value)
fun main() {
val map = mutableMapOf<Set<Int>, String>()
map.put2(1, 2, 3, value = "x") // no errors
map.put2(1, 2, 3, "x") // compiler error: No value passed for parameter 'value'
}
wouldn't it make sense for the compiler to figure the last argument on its own in this scenario?Casey Brooks
01/31/2020, 6:25 PMvalue
into a lambda parameter?
inline fun <K, V> MutableMap<Set<K>, V>.put2(vararg keys: K, value: ()->V) = put(keys.toSet(), value())
fun main() {
val map = mutableMapOf<Set<Int>, String>()
map.put2(1, 2, 3) { "x" }
}
StavFX
01/31/2020, 6:25 PMmap
to Map<Set<Any>, String>> do you still expect “x” to be value? Or should it be part of keys
then?LS
01/31/2020, 6:28 PMStavFX
01/31/2020, 6:49 PM