Skip to content

Instantly share code, notes, and snippets.

@seoft
Last active January 17, 2020 14:12
Show Gist options
  • Save seoft/35d004fbc3cb628c1febc9e21fc4a8e6 to your computer and use it in GitHub Desktop.
Save seoft/35d004fbc3cb628c1febc9e21fc4a8e6 to your computer and use it in GitHub Desktop.
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]
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