Newbie question : issue with how kotlin.Unit works when using map
Hi there!
Sorry if the questions sounds stupid, but I am new to Kotlin.
fun test() {
val parameters = listOf("val1", "val2", "val3")
parameters.map { println(it) }
println(parameters)
}
Output is :
val1
val2
val3
[val1, val2, val3]
But I was expecting :
val1
val2
val3
[kotlin.Unit, kotlin.Unit, kotlin.Unit]
Since the return value of the “println” function is kotlin.Unit, I don’t understand why the values of “parameters” are not altered by the map operation… So in that case what is...