W3cubDocs

/Kotlin

sumBy

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
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
@ExperimentalUnsignedTypes inline fun UIntArray.sumBy(
    selector: (UInt) -> UInt
): UInt
@ExperimentalUnsignedTypes inline fun ULongArray.sumBy(
    selector: (ULong) -> UInt
): UInt
@ExperimentalUnsignedTypes inline fun UByteArray.sumBy(
    selector: (UByte) -> UInt
): UInt
@ExperimentalUnsignedTypes inline fun UShortArray.sumBy(
    selector: (UShort) -> UInt
): UInt

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

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
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.

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