W3cubDocs

/Kotlin

distinctBy

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
inline fun <T, K> Array<out T>.distinctBy(
    selector: (T) -> K
): List<T>
inline fun <K> ByteArray.distinctBy(
    selector: (Byte) -> K
): List<Byte>
inline fun <K> ShortArray.distinctBy(
    selector: (Short) -> K
): List<Short>
inline fun <K> IntArray.distinctBy(
    selector: (Int) -> K
): List<Int>
inline fun <K> LongArray.distinctBy(
    selector: (Long) -> K
): List<Long>
inline fun <K> FloatArray.distinctBy(
    selector: (Float) -> K
): List<Float>
inline fun <K> DoubleArray.distinctBy(
    selector: (Double) -> K
): List<Double>
inline fun <K> BooleanArray.distinctBy(
    selector: (Boolean) -> K
): List<Boolean>
inline fun <K> CharArray.distinctBy(
    selector: (Char) -> K
): List<Char>

Returns a list containing only elements from the given array having distinct keys returned by the given selector function.

The elements in the resulting list are in the same order as they were in the source array.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
inline fun <T, K> Iterable<T>.distinctBy(
    selector: (T) -> K
): List<T>

Returns a list containing only elements from the given collection having distinct keys returned by the given selector function.

The elements in the resulting list are in the same order as they were in the source collection.

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