Is it possible to pass in a collection (e.g. a list) into a function which takes varargs?
Here is my example code which doesn’t compile:
data class Parameter(val name: String, val required: Boolean)
fun mapByName(params: List<Parameter>): Map<String, Parameter> {
val pairs = params.map { param -> Pair(param.name, param) }
val mappedPairs = mapOf(pairs)
return mappedPairs
}
The error I get is:
Error:(15, 35) Kotlin: Too many arguments for public fun <K, V> mapOf(): kotlin.Map<K, V> defined in kotlin