You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Kotlin collections provides helper method like sumOf { }, but some methods are defined with the explicit types (there is a Iterable<T>.sumOf(selector: (T) -> Long): Long and a Iterable<T>.sumOf(selector: (T) -> Int): Int for example).
data classFoo(valdata:Double)
val fooList =listOf(Foo(0.1), Foo(0.2))
val sum = fooList.sumOf { it.data }
It could be nice to provide those methods for BigInteger and BigDecimal.
Describe the solution you'd like
data classBar(valdata:BigDecimal)
val barList =listOf(Bar(BigDecimal.fromDouble(0.1)), Bar(BigDecimal.fromDouble(0.2)))
val sum = barList.sumOf { it.data }
Describe alternatives you've considered
It's still possible to use fold to compute a sum (just a bit less convenient).
val sum2 = barList.fold(BigDecimal.ZERO) { acc, it -> acc + it.data }
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Kotlin collections provides helper method like
sumOf { }
, but some methods are defined with the explicit types (there is aIterable<T>.sumOf(selector: (T) -> Long): Long
and aIterable<T>.sumOf(selector: (T) -> Int): Int
for example).It could be nice to provide those methods for BigInteger and BigDecimal.
Describe the solution you'd like
Describe alternatives you've considered
It's still possible to use
fold
to compute a sum (just a bit less convenient).The text was updated successfully, but these errors were encountered: