KT-33761 Add reduceRightOrNull

This commit is contained in:
Alfredo Delli Bovi
2019-12-13 19:06:59 +01:00
committed by Ilya Gorbunov
parent f5d696d3c4
commit 06008c40ab
7 changed files with 321 additions and 0 deletions
@@ -335,6 +335,15 @@ class CollectionTest {
}
}
@Test fun reduceRightOrNull() {
expect("1234") {
val list = listOf("1", "2", "3", "4")
list.reduceRightOrNull { a, b -> a + b }
}
expect(null, { arrayListOf<Int>().reduceRightOrNull { a, b -> a + b } })
}
@Test fun groupBy() {
val words = listOf("a", "abc", "ab", "def", "abcd")
val byLength = words.groupBy { it.length }