Provide unzip method for Iterables, Arrays and Sequences of pairs.
#KT-5793 Fixed
This commit is contained in:
@@ -621,6 +621,19 @@ class CollectionTest {
|
||||
assertEquals(e, 5)
|
||||
}
|
||||
|
||||
test fun unzipList() {
|
||||
val list = listOf(1 to 'a', 2 to 'b', 3 to 'c')
|
||||
val (ints, chars) = list.unzip()
|
||||
assertEquals(listOf(1, 2, 3), ints)
|
||||
assertEquals(listOf('a', 'b', 'c'), chars)
|
||||
}
|
||||
|
||||
test fun unzipArray() {
|
||||
val array = arrayOf(1 to 'a', 2 to 'b', 3 to 'c')
|
||||
val (ints, chars) = array.unzip()
|
||||
assertEquals(listOf(1, 2, 3), ints)
|
||||
assertEquals(listOf('a', 'b', 'c'), chars)
|
||||
}
|
||||
|
||||
test fun specialLists() {
|
||||
compare(arrayListOf<Int>(), listOf<Int>()) { listBehavior() }
|
||||
|
||||
Reference in New Issue
Block a user