W3cubDocs

/Kotlin

sumBy

inline fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int

Returns the sum of all values produced by selector function applied to each element in the collection.

inline fun <T> Array<out T>.sumBy(selector: (T) -> Int): Int
inline fun ByteArray.sumBy(selector: (Byte) -> Int): Int
inline fun ShortArray.sumBy(selector: (Short) -> Int): Int
inline fun IntArray.sumBy(selector: (Int) -> Int): Int
inline fun LongArray.sumBy(selector: (Long) -> Int): Int
inline fun FloatArray.sumBy(selector: (Float) -> Int): Int
inline fun DoubleArray.sumBy(selector: (Double) -> Int): Int
inline fun BooleanArray.sumBy(
    selector: (Boolean) -> Int
): Int
inline fun CharArray.sumBy(selector: (Char) -> Int): Int

Returns the sum of all values produced by selector function applied to each element in the array.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sum-by.html