Last active
January 17, 2020 14:12
-
-
Save seoft/35d004fbc3cb628c1febc9e21fc4a8e6 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 list1 = listOf<Int>(1, 2, 3) | |
val list2 = listOf<Int>(7, 8, 9) | |
val resultList1 = mutableListOf<Int>().apply { | |
addAll(list1) | |
add(4) | |
add(5) | |
add(6) | |
addAll(list2) | |
}.toList() // [1, 2, 3, 4, 5, 6, 7, 8, 9] |
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 list1 = listOf<Int>(1, 2, 3) | |
val list2 = listOf<Int>(7, 8, 9) | |
val resultList2 = listOf(*list1.toTypedArray(), 4, 5, 6, *list2.toTypedArray()) // [1, 2, 3, 4, 5, 6, 7, 8, 9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment