In the following code, both println() calls output the same…
In the following code, both println() calls output the same list because map() modifies the values of numbers and returns a reference to the list. val numbers = listOf(1, 2, 3, 4, 5) val doubled = numbers.map { it * 2 } println(numbers) // OUTPUT: [2, 4, 6, 8, 10] println(doubled) // OUTPUT: [2, 4, 6, 8, 10]
Read Details