Created
November 16, 2021 16:29
-
-
Save EmmanuelGuther/681096d24d4162a9b7b8d731bf2fe6cb to your computer and use it in GitHub Desktop.
kotlin collections build-list
This file contains hidden or 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
For those cases where you have to calculate the elements before adding them to the list, | |
you "save" the boilerplate of creating a mutable list and then returning an immutable list. | |
The example of the docs is... but it is understood where it goes. | |
val y = buildList () { | |
add ('a') | |
addAll (x) | |
add ('d') | |
} | |
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/build-list.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment