Created
August 12, 2023 12:30
-
-
Save faizul14/80f9b0b286d8387b912e5261fb36b9ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val numbers = mutableListOf(1, 2, 3) | |
val doubled = numbers.also { | |
it.add(4) | |
it.mapInPlace { num -> num * 2 } | |
} | |
println("Original List: $numbers") | |
println("Doubled List: $doubled") | |
// Output: | |
// Original List: [1, 2, 3, 4] | |
// Doubled List: [2, 4, 6, 8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment