W3cubDocs

/Kotlin

partition

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

Splits the original array into pair of lists, where first list contains elements for which predicate yielded true, while second list contains elements for which predicate yielded false.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
inline fun <T> Iterable<T>.partition(
    predicate: (T) -> Boolean
): Pair<List<T>, List<T>>

Splits the original collection into pair of lists, where first list contains elements for which predicate yielded true, while second list contains elements for which predicate yielded false.

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