KT-33761 Add reduceOrNull

This commit is contained in:
Alfredo Delli Bovi
2019-12-11 08:31:18 +01:00
committed by Ilya Gorbunov
parent 39e1b24c2c
commit f5d696d3c4
10 changed files with 345 additions and 0 deletions
@@ -315,6 +315,15 @@ class CollectionTest {
}
}
@Test fun reduceOrNull() {
expect("1234") {
val list = listOf("1", "2", "3", "4")
list.reduceOrNull { a, b -> a + b }
}
expect(null, { arrayListOf<Int>().reduceOrNull { a, b -> a + b } })
}
@Test fun reduceRight() {
expect("1234") {
val list = listOf("1", "2", "3", "4")