code
stringlengths
2.5k
150k
kind
stringclasses
1 value
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` const val SIZE_BYTES: Int ``` The number of bytes used to represent an instance of Byte in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [MIN\_VALUE](-m-i-n_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MIN_VALUE: Byte ``` A constant holding the minimum value an instance of Byte can have. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toLong(): Long ``` Converts this [Byte](index#kotlin.Byte) value to [Long](../-long/index#kotlin.Long). The resulting `Long` value represents the same numerical value as this `Byte`. The least significant 8 bits of the resulting `Long` value are the same as the bits of this `Byte` value, whereas the most significant 56 bits are filled with the sign bit of this value. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [MAX\_VALUE](-m-a-x_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MAX_VALUE: Byte ``` A constant holding the maximum value an instance of Byte can have. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun compareTo(other: Byte): Int ``` ``` operator fun compareTo(other: Short): Int ``` ``` operator fun compareTo(other: Int): Int ``` ``` operator fun compareTo(other: Long): Int ``` ``` operator fun compareTo(other: Float): Int ``` ``` operator fun compareTo(other: Double): Int ``` Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other. kotlin rangeTo rangeTo ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [rangeTo](range-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rangeTo(other: Byte): IntRange ``` ``` operator fun rangeTo(other: Short): IntRange ``` ``` operator fun rangeTo(other: Int): IntRange ``` ``` operator fun rangeTo(other: Long): LongRange ``` Creates a range from this value to the specified [other](range-to#kotlin.Byte%24rangeTo(kotlin.Byte)/other) value. kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / <rem> **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun rem(other: Byte): Int ``` ``` operator fun rem(other: Short): Int ``` ``` operator fun rem(other: Int): Int ``` ``` operator fun rem(other: Long): Long ``` ``` operator fun rem(other: Float): Float ``` ``` operator fun rem(other: Double): Double ``` Calculates the remainder of truncating division of this value by the other value. The result is either zero or has the same sign as the *dividend* and has the absolute value less than the absolute value of the divisor. kotlin rangeUntil rangeUntil ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [rangeUntil](range-until) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Byte ): IntRange ``` ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Short ): IntRange ``` ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Int ): IntRange ``` ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Long ): LongRange ``` Creates a range from this value up to but excluding the specified [other](range-until#kotlin.Byte%24rangeUntil(kotlin.Byte)/other) value. If the [other](range-until#kotlin.Byte%24rangeUntil(kotlin.Byte)/other) value is less than or equal to `this` value, then the returned range is empty. kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / <div> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: Byte): Int ``` ``` operator fun div(other: Short): Int ``` ``` operator fun div(other: Int): Int ``` ``` operator fun div(other: Long): Long ``` Divides this value by the other value, truncating the result to an integer that is closer to zero. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: Float): Float ``` ``` operator fun div(other: Double): Double ``` Divides this value by the other value. kotlin toDouble toDouble ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toDouble(): Double ``` Converts this [Byte](index#kotlin.Byte) value to [Double](../-double/index#kotlin.Double). The resulting `Double` value represents the same numerical value as this `Byte`. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun dec(): Byte ``` Returns this value decremented by one. ``` fun main(args: Array<String>) { //sampleStart val a = 3 val b = a.dec() println(a) // 3 println(b) // 2 var x = 3 val y = x-- println(x) // 2 println(y) // 3 val z = --x println(x) // 1 println(z) // 1 //sampleEnd } ``` kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [hashCode](hash-code) **Platform and version requirements:** Native (1.3) ``` fun hashCode(): Int ``` Returns a hash code value for the object. The general contract of `hashCode` is: * Whenever it is invoked on the same object more than once, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. * If two objects are equal according to the `equals()` method, then calling the `hashCode` method on each of the two objects must produce the same integer result. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun inc(): Byte ``` Returns this value incremented by one. ``` fun main(args: Array<String>) { //sampleStart val a = 3 val b = a.inc() println(a) // 3 println(b) // 4 var x = 3 val y = x++ println(x) // 4 println(y) // 3 val z = ++x println(x) // 5 println(z) // 5 //sampleEnd } ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toString(): String ``` Returns a string representation of the object. kotlin unaryMinus unaryMinus ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [unaryMinus](unary-minus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryMinus(): Int ``` Returns the negative of this value. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun equals(other: Any?): Boolean ``` Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: * Reflexive: for any non-null value `x`, `x.equals(x)` should return true. * Symmetric: for any non-null values `x` and `y`, `x.equals(y)` should return true if and only if `y.equals(x)` returns true. * Transitive: for any non-null values `x`, `y`, and `z`, if `x.equals(y)` returns true and `y.equals(z)` returns true, then `x.equals(z)` should return true. * Consistent: for any non-null values `x` and `y`, multiple invocations of `x.equals(y)` consistently return true or consistently return false, provided no information used in `equals` comparisons on the objects is modified. * Never equal to null: for any non-null value `x`, `x.equals(null)` should return false. Read more about [equality](../../../../../../docs/equality) in Kotlin. **Platform and version requirements:** Native (1.3) ``` fun equals(other: Byte): Boolean ``` kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / <times> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun times(other: Byte): Int ``` ``` operator fun times(other: Short): Int ``` ``` operator fun times(other: Int): Int ``` ``` operator fun times(other: Long): Long ``` ``` operator fun times(other: Float): Float ``` ``` operator fun times(other: Double): Double ``` Multiplies this value by the other value. kotlin toFloat toFloat ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toFloat(): Float ``` Converts this [Byte](index#kotlin.Byte) value to [Float](../-float/index#kotlin.Float). The resulting `Float` value represents the same numerical value as this `Byte`. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: Byte): Int ``` ``` operator fun minus(other: Short): Int ``` ``` operator fun minus(other: Int): Int ``` ``` operator fun minus(other: Long): Long ``` ``` operator fun minus(other: Float): Float ``` ``` operator fun minus(other: Double): Double ``` Subtracts the other value from this value. kotlin toShort toShort ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toShort(): Short ``` Converts this [Byte](index#kotlin.Byte) value to [Short](../-short/index#kotlin.Short). The resulting `Short` value represents the same numerical value as this `Byte`. The least significant 8 bits of the resulting `Short` value are the same as the bits of this `Byte` value, whereas the most significant 8 bits are filled with the sign bit of this value. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun plus(other: Byte): Int ``` ``` operator fun plus(other: Short): Int ``` ``` operator fun plus(other: Int): Int ``` ``` operator fun plus(other: Long): Long ``` ``` operator fun plus(other: Float): Float ``` ``` operator fun plus(other: Double): Double ``` Adds the other value to this value. kotlin toChar toChar ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [toChar](to-char) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.5") fun toChar(): Char ``` **Deprecated:** Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. Converts this [Byte](index#kotlin.Byte) value to [Char](../-char/index#kotlin.Char). If this value is non-negative, the resulting `Char` code is equal to this value. The least significant 8 bits of the resulting `Char` code are the same as the bits of this `Byte` value, whereas the most significant 8 bits are filled with the sign bit of this value. kotlin ExtensionFunctionType ExtensionFunctionType ===================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExtensionFunctionType](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @Target([AnnotationTarget.TYPE]) annotation class ExtensionFunctionType ``` Signifies that the annotated functional type represents an extension function. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Signifies that the annotated functional type represents an extension function. ``` <init>() ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotationClass](../../kotlin.jvm/annotation-class) Returns a [KClass](../../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance corresponding to the annotation type of this annotation. ``` val <T : Annotation> T.annotationClass: KClass<out T> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExtensionFunctionType](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>() ``` Signifies that the annotated functional type represents an extension function. kotlin OverloadResolutionByLambdaReturnType OverloadResolutionByLambdaReturnType ==================================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [OverloadResolutionByLambdaReturnType](index) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @Target([AnnotationTarget.FUNCTION]) @ExperimentalTypeInference annotation class OverloadResolutionByLambdaReturnType ``` Enables overload selection based on the type of the value returned from lambda argument. When two or more function overloads have otherwise the same parameter lists that differ only in the return type of a functional parameter, this annotation enables overload selection by the type of the value returned from the lambda function passed to this functional parameter. Example: ``` @OverloadResolutionByLambdaReturnType fun create(intProducer: () -> Int): Int fun create(doubleProducer: () -> Double): Double val newValue = create { 3.14 } ``` The annotation being applied to one of overloads allows to resolve this ambiguity by analyzing what value is returned from the lambda function. This annotation is also used to discriminate the annotated overloads in case if overload selection still cannot choose one of them even taking in account the result of lambda parameter analysis. In that case a warning is reported. Note: this annotation is experimental, see [ExperimentalTypeInference](../../kotlin.experimental/-experimental-type-inference/index) on how to opt-in for it. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Enables overload selection based on the type of the value returned from lambda argument. ``` OverloadResolutionByLambdaReturnType() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [OverloadResolutionByLambdaReturnType](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` OverloadResolutionByLambdaReturnType() ``` Enables overload selection based on the type of the value returned from lambda argument. When two or more function overloads have otherwise the same parameter lists that differ only in the return type of a functional parameter, this annotation enables overload selection by the type of the value returned from the lambda function passed to this functional parameter. Example: ``` @OverloadResolutionByLambdaReturnType fun create(intProducer: () -> Int): Int fun create(doubleProducer: () -> Double): Double val newValue = create { 3.14 } ``` The annotation being applied to one of overloads allows to resolve this ambiguity by analyzing what value is returned from the lambda function. This annotation is also used to discriminate the annotated overloads in case if overload selection still cannot choose one of them even taking in account the result of lambda parameter analysis. In that case a warning is reported. Note: this annotation is experimental, see [ExperimentalTypeInference](../../kotlin.experimental/-experimental-type-inference/index) on how to opt-in for it. kotlin message message ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throwable](index) / <message> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` open val message: String? ``` the detail message string. kotlin Throwable Throwable ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throwable](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` open class Throwable ``` The base class for all errors and exceptions. Only instances of this class can be thrown or caught. Parameters ---------- `message` - the detail message string. `cause` - the cause of this throwable. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) ``` <init>(message: String?) ``` ``` <init>(cause: Throwable?) ``` ``` <init>() ``` The base class for all errors and exceptions. Only instances of this class can be thrown or caught. ``` <init>(message: String?, cause: Throwable?) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <cause> the cause of this throwable. ``` open val cause: Throwable? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <message> the detail message string. ``` open val message: String? ``` Functions --------- **Platform and version requirements:** Native (1.3) #### [getStackTrace](get-stack-trace) Returns an array of stack trace strings representing the stack trace pertaining to this throwable. ``` fun getStackTrace(): Array<String> ``` **Platform and version requirements:** Native (1.3) #### [printStackTrace](print-stack-trace) Prints the [detailed description](../stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the standard output. ``` fun printStackTrace() ``` **Platform and version requirements:** Native (1.3) #### [toString](to-string) Returns the short description of this throwable consisting of the exception class name (fully qualified if possible) followed by the exception message if it is not null. ``` open fun toString(): String ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [stackTrace](../stack-trace) Returns an array of stack trace elements representing the stack trace pertaining to this throwable. ``` val Throwable.stackTrace: Array<StackTraceElement> ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](../../kotlin.native/get-stack-trace-addresses) Returns a list of stack trace addresses representing the stack trace pertaining to this throwable. ``` fun Throwable.getStackTraceAddresses(): List<Long> ``` **Platform and version requirements:** JVM (1.0) #### [printStackTrace](../print-stack-trace) Prints the [detailed description](../stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [writer](../print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintWriter)/writer). ``` fun Throwable.printStackTrace(writer: PrintWriter) ``` Prints the [detailed description](../stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [stream](../print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintStream)/stream). ``` fun Throwable.printStackTrace(stream: PrintStream) ``` Inheritors ---------- #### [Error](../-error/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class Error : Throwable ``` **Platform and version requirements:** JVM (1.1) ``` typealias Error = Error ``` #### [Exception](../-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class Exception : Throwable ``` **Platform and version requirements:** JVM (1.1) ``` typealias Exception = Exception ```
programming_docs
kotlin cause cause ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throwable](index) / <cause> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` open val cause: Throwable? ``` the cause of this throwable. kotlin printStackTrace printStackTrace =============== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throwable](index) / [printStackTrace](print-stack-trace) **Platform and version requirements:** Native (1.3) ``` fun printStackTrace() ``` Prints the [detailed description](../stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the standard output. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throwable](index) / [toString](to-string) **Platform and version requirements:** Native (1.3) ``` open fun toString(): String ``` Returns the short description of this throwable consisting of the exception class name (fully qualified if possible) followed by the exception message if it is not null. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throwable](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(message: String?) ``` ``` <init>(cause: Throwable?) ``` ``` <init>() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(message: String?, cause: Throwable?) ``` The base class for all errors and exceptions. Only instances of this class can be thrown or caught. Parameters ---------- `message` - the detail message string. `cause` - the cause of this throwable. kotlin getStackTrace getStackTrace ============= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throwable](index) / [getStackTrace](get-stack-trace) **Platform and version requirements:** Native (1.3) ``` fun getStackTrace(): Array<String> ``` Returns an array of stack trace strings representing the stack trace pertaining to this throwable. kotlin SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [SIZE\_BITS](-s-i-z-e_-b-i-t-s) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val SIZE_BITS: Int ``` The number of bits used to represent an instance of UShort in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toInt(): Int ``` Converts this [UShort](index) value to [Int](../-int/index#kotlin.Int). The resulting `Int` value represents the same numerical value as this `UShort`. The least significant 16 bits of the resulting `Int` value are the same as the bits of this `UShort` value, whereas the most significant 16 bits are filled with zeros. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toByte(): Byte ``` Converts this [UShort](index) value to [Byte](../-byte/index#kotlin.Byte). If this value is less than or equals to [Byte.MAX\_VALUE](../-byte/-m-a-x_-v-a-l-u-e#kotlin.Byte.Companion%24MAX_VALUE), the resulting `Byte` value represents the same numerical value as this `UShort`. The resulting `Byte` value is represented by the least significant 8 bits of this `UShort` value. Note that the resulting `Byte` value may be negative. kotlin UShort UShort ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline class UShort : Comparable<UShort> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <and> Performs a bitwise AND operation between the two values. ``` infix fun and(other: UShort): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareTo](compare-to) Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other. ``` operator fun compareTo(other: UByte): Int ``` ``` operator fun compareTo(other: UShort): Int ``` ``` operator fun compareTo(other: UInt): Int ``` ``` operator fun compareTo(other: ULong): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <dec> Returns this value decremented by one. ``` operator fun dec(): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <div> Divides this value by the other value, truncating the result to an integer that is closer to zero. ``` operator fun div(other: UByte): UInt ``` ``` operator fun div(other: UShort): UInt ``` ``` operator fun div(other: UInt): UInt ``` ``` operator fun div(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [floorDiv](floor-div) Divides this value by the other value, flooring the result to an integer that is closer to negative infinity. ``` fun floorDiv(other: UByte): UInt ``` ``` fun floorDiv(other: UShort): UInt ``` ``` fun floorDiv(other: UInt): UInt ``` ``` fun floorDiv(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inc> Returns this value incremented by one. ``` operator fun inc(): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inv> Inverts the bits in this value. ``` fun inv(): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <minus> Subtracts the other value from this value. ``` operator fun minus(other: UByte): UInt ``` ``` operator fun minus(other: UShort): UInt ``` ``` operator fun minus(other: UInt): UInt ``` ``` operator fun minus(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <mod> Calculates the remainder of flooring division of this value by the other value. ``` fun mod(other: UByte): UByte ``` ``` fun mod(other: UShort): UShort ``` ``` fun mod(other: UInt): UInt ``` ``` fun mod(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <or> Performs a bitwise OR operation between the two values. ``` infix fun or(other: UShort): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Adds the other value to this value. ``` operator fun plus(other: UByte): UInt ``` ``` operator fun plus(other: UShort): UInt ``` ``` operator fun plus(other: UInt): UInt ``` ``` operator fun plus(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](range-to) Creates a range from this value to the specified [other](range-to#kotlin.UShort%24rangeTo(kotlin.UShort)/other) value. ``` operator fun rangeTo(other: UShort): UIntRange ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [rangeUntil](range-until) Creates a range from this value up to but excluding the specified [other](range-until#kotlin.UShort%24rangeUntil(kotlin.UShort)/other) value. ``` operator fun rangeUntil(other: UShort): UIntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <rem> Calculates the remainder of truncating division of this value by the other value. ``` operator fun rem(other: UByte): UInt ``` ``` operator fun rem(other: UShort): UInt ``` ``` operator fun rem(other: UInt): UInt ``` ``` operator fun rem(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <times> Multiplies this value by the other value. ``` operator fun times(other: UByte): UInt ``` ``` operator fun times(other: UShort): UInt ``` ``` operator fun times(other: UInt): UInt ``` ``` operator fun times(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Converts this [UShort](index) value to [Byte](../-byte/index#kotlin.Byte). ``` fun toByte(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDouble](to-double) Converts this [UShort](index) value to [Double](../-double/index#kotlin.Double). ``` fun toDouble(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloat](to-float) Converts this [UShort](index) value to [Float](../-float/index#kotlin.Float). ``` fun toFloat(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toInt](to-int) Converts this [UShort](index) value to [Int](../-int/index#kotlin.Int). ``` fun toInt(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLong](to-long) Converts this [UShort](index) value to [Long](../-long/index#kotlin.Long). ``` fun toLong(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShort](to-short) Converts this [UShort](index) value to [Short](../-short/index#kotlin.Short). ``` fun toShort(): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns a string representation of the object. ``` fun toString(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toUByte](to-u-byte) Converts this [UShort](index) value to [UByte](../-u-byte/index). ``` fun toUByte(): UByte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toUInt](to-u-int) Converts this [UShort](index) value to [UInt](../-u-int/index). ``` fun toUInt(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toULong](to-u-long) Converts this [UShort](index) value to [ULong](../-u-long/index). ``` fun toULong(): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toUShort](to-u-short) Returns this value. ``` fun toUShort(): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <xor> Performs a bitwise XOR operation between the two values. ``` infix fun xor(other: UShort): UShort ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MAX\_VALUE](-m-a-x_-v-a-l-u-e) A constant holding the maximum value an instance of UShort can have. ``` const val MAX_VALUE: UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MIN\_VALUE](-m-i-n_-v-a-l-u-e) A constant holding the minimum value an instance of UShort can have. ``` const val MIN_VALUE: UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SIZE\_BITS](-s-i-z-e_-b-i-t-s) The number of bits used to represent an instance of UShort in a binary form. ``` const val SIZE_BITS: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) The number of bytes used to represent an instance of UShort in a binary form. ``` const val SIZE_BYTES: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceAtLeast](../../kotlin.ranges/coerce-at-least) Ensures that this value is not less than the specified [minimumValue](../../kotlin.ranges/coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.UShort,%20kotlin.UShort)/minimumValue). ``` fun UShort.coerceAtLeast(minimumValue: UShort): UShort ``` ``` fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceAtMost](../../kotlin.ranges/coerce-at-most) Ensures that this value is not greater than the specified [maximumValue](../../kotlin.ranges/coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.UShort,%20kotlin.UShort)/maximumValue). ``` fun UShort.coerceAtMost(maximumValue: UShort): UShort ``` ``` fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceIn](../../kotlin.ranges/coerce-in) Ensures that this value lies in the specified range [minimumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.UShort,%20kotlin.UShort,%20kotlin.UShort)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.UShort,%20kotlin.UShort,%20kotlin.UShort)/maximumValue). ``` fun UShort.coerceIn(     minimumValue: UShort,     maximumValue: UShort ): UShort ``` ``` fun <T : Comparable<T>> T.coerceIn(     minimumValue: T?,     maximumValue: T? ): T ``` Ensures that this value lies in the specified [range](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.ClosedFloatingPointRange((kotlin.ranges.coerceIn.T)))/range). ``` fun <T : Comparable<T>> T.coerceIn(     range: ClosedFloatingPointRange<T> ): T ``` ``` fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [compareTo](../compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other) object, a negative number if it's less than [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other), or a positive number if it's greater than [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other). ``` infix fun <T> Comparable<T>.compareTo(other: T): Int ``` **Platform and version requirements:** Native (1.3) #### [convert](../../kotlinx.cinterop/convert) ``` fun <R : Any> UShort.convert(): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [countLeadingZeroBits](../count-leading-zero-bits) Counts the number of consecutive most significant bits that are zero in the binary representation of this [UShort](index) number. ``` fun UShort.countLeadingZeroBits(): Int ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [countOneBits](../count-one-bits) Counts the number of set bits in the binary representation of this [UShort](index) number. ``` fun UShort.countOneBits(): Int ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [countTrailingZeroBits](../count-trailing-zero-bits) Counts the number of consecutive least significant bits that are zero in the binary representation of this [UShort](index) number. ``` fun UShort.countTrailingZeroBits(): Int ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [downTo](../../kotlin.ranges/down-to) Returns a progression from this value down to the specified [to](../../kotlin.ranges/down-to#kotlin.ranges%24downTo(kotlin.UShort,%20kotlin.UShort)/to) value with the step -1. ``` infix fun UShort.downTo(to: UShort): UIntProgression ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](../../kotlin.ranges/range-to) Creates a range from this [Comparable](../-comparable/index#kotlin.Comparable) value to the specified [that](../../kotlin.ranges/range-to#kotlin.ranges%24rangeTo(kotlin.ranges.rangeTo.T,%20kotlin.ranges.rangeTo.T)/that) value. ``` operator fun <T : Comparable<T>> T.rangeTo(     that: T ): ClosedRange<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [rangeUntil](../../kotlin.ranges/range-until) Creates an open-ended range from this [Comparable](../-comparable/index#kotlin.Comparable) value to the specified [that](../../kotlin.ranges/range-until#kotlin.ranges%24rangeUntil(kotlin.ranges.rangeUntil.T,%20kotlin.ranges.rangeUntil.T)/that) value. ``` operator fun <T : Comparable<T>> T.rangeUntil(     that: T ): OpenEndRange<T> ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateLeft](../rotate-left) Rotates the binary representation of this [UShort](index) number left by the specified [bitCount](../rotate-left#kotlin%24rotateLeft(kotlin.UShort,%20kotlin.Int)/bitCount) number of bits. The most significant bits pushed out from the left side reenter the number as the least significant bits on the right side. ``` fun UShort.rotateLeft(bitCount: Int): UShort ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateRight](../rotate-right) Rotates the binary representation of this [UShort](index) number right by the specified [bitCount](../rotate-right#kotlin%24rotateRight(kotlin.UShort,%20kotlin.Int)/bitCount) number of bits. The least significant bits pushed out from the right side reenter the number as the most significant bits on the left side. ``` fun UShort.rotateRight(bitCount: Int): UShort ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [takeHighestOneBit](../take-highest-one-bit) Returns a number having a single bit set in the position of the most significant set bit of this [UShort](index) number, or zero, if this number is zero. ``` fun UShort.takeHighestOneBit(): UShort ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [takeLowestOneBit](../take-lowest-one-bit) Returns a number having a single bit set in the position of the least significant set bit of this [UShort](index) number, or zero, if this number is zero. ``` fun UShort.takeLowestOneBit(): UShort ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toString](../../kotlin.text/to-string) Returns a string representation of this [Short](../-short/index#kotlin.Short) value in the specified [radix](../../kotlin.text/to-string#kotlin.text%24toString(kotlin.UShort,%20kotlin.Int)/radix). ``` fun UShort.toString(radix: Int): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [until](../../kotlin.ranges/until) Returns a range from this value up to but excluding the specified [to](../../kotlin.ranges/until#kotlin.ranges%24until(kotlin.UShort,%20kotlin.UShort)/to) value. ``` infix fun UShort.until(to: UShort): UIntRange ``` kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val SIZE_BYTES: Int ``` The number of bytes used to represent an instance of UShort in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [MIN\_VALUE](-m-i-n_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val MIN_VALUE: UShort ``` A constant holding the minimum value an instance of UShort can have.
programming_docs
kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toLong(): Long ``` Converts this [UShort](index) value to [Long](../-long/index#kotlin.Long). The resulting `Long` value represents the same numerical value as this `UShort`. The least significant 16 bits of the resulting `Long` value are the same as the bits of this `UShort` value, whereas the most significant 48 bits are filled with zeros. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [MAX\_VALUE](-m-a-x_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val MAX_VALUE: UShort ``` A constant holding the maximum value an instance of UShort can have. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun compareTo(other: UByte): Int ``` ``` operator fun compareTo(other: UShort): Int ``` ``` operator fun compareTo(other: UInt): Int ``` ``` operator fun compareTo(other: ULong): Int ``` Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other. kotlin rangeTo rangeTo ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [rangeTo](range-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rangeTo(other: UShort): UIntRange ``` Creates a range from this value to the specified [other](range-to#kotlin.UShort%24rangeTo(kotlin.UShort)/other) value. kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <rem> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rem(other: UByte): UInt ``` ``` operator fun rem(other: UShort): UInt ``` ``` operator fun rem(other: UInt): UInt ``` ``` operator fun rem(other: ULong): ULong ``` Calculates the remainder of truncating division of this value by the other value. The result is always less than the divisor. kotlin rangeUntil rangeUntil ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [rangeUntil](range-until) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: UShort ): UIntRange ``` Creates a range from this value up to but excluding the specified [other](range-until#kotlin.UShort%24rangeUntil(kotlin.UShort)/other) value. If the [other](range-until#kotlin.UShort%24rangeUntil(kotlin.UShort)/other) value is less than or equal to `this` value, then the returned range is empty. kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <div> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: UByte): UInt ``` ``` operator fun div(other: UShort): UInt ``` ``` operator fun div(other: UInt): UInt ``` ``` operator fun div(other: ULong): ULong ``` Divides this value by the other value, truncating the result to an integer that is closer to zero. kotlin toDouble toDouble ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toDouble(): Double ``` Converts this [UShort](index) value to [Double](../-double/index#kotlin.Double). The resulting `Double` value represents the same numerical value as this `UShort`. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun dec(): UShort ``` Returns this value decremented by one. ``` fun main(args: Array<String>) { //sampleStart val a = 3 val b = a.dec() println(a) // 3 println(b) // 2 var x = 3 val y = x-- println(x) // 2 println(y) // 3 val z = --x println(x) // 1 println(z) // 1 //sampleEnd } ``` kotlin and and === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <and> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun and(other: UShort): UShort ``` Performs a bitwise AND operation between the two values. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun inc(): UShort ``` Returns this value incremented by one. ``` fun main(args: Array<String>) { //sampleStart val a = 3 val b = a.inc() println(a) // 3 println(b) // 4 var x = 3 val y = x++ println(x) // 4 println(y) // 3 val z = ++x println(x) // 5 println(z) // 5 //sampleEnd } ``` kotlin inv inv === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <inv> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun inv(): UShort ``` Inverts the bits in this value. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toString(): String ``` Returns a string representation of the object. kotlin toUInt toUInt ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toUInt](to-u-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUInt(): UInt ``` Converts this [UShort](index) value to [UInt](../-u-int/index). The resulting `UInt` value represents the same numerical value as this `UShort`. The least significant 16 bits of the resulting `UInt` value are the same as the bits of this `UShort` value, whereas the most significant 16 bits are filled with zeros. kotlin xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <xor> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun xor(other: UShort): UShort ``` Performs a bitwise XOR operation between the two values. kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <times> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun times(other: UByte): UInt ``` ``` operator fun times(other: UShort): UInt ``` ``` operator fun times(other: UInt): UInt ``` ``` operator fun times(other: ULong): ULong ``` Multiplies this value by the other value. kotlin mod mod === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <mod> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun mod(other: UByte): UByte ``` ``` fun mod(other: UShort): UShort ``` ``` fun mod(other: UInt): UInt ``` ``` fun mod(other: ULong): ULong ``` Calculates the remainder of flooring division of this value by the other value. The result is always less than the divisor. For unsigned types, the remainders of flooring division and truncating division are the same. kotlin toFloat toFloat ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toFloat(): Float ``` Converts this [UShort](index) value to [Float](../-float/index#kotlin.Float). The resulting `Float` value represents the same numerical value as this `UShort`. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: UByte): UInt ``` ``` operator fun minus(other: UShort): UInt ``` ``` operator fun minus(other: UInt): UInt ``` ``` operator fun minus(other: ULong): ULong ``` Subtracts the other value from this value. kotlin toUByte toUByte ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toUByte](to-u-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUByte(): UByte ``` Converts this [UShort](index) value to [UByte](../-u-byte/index). If this value is less than or equals to [UByte.MAX\_VALUE](../-u-byte/-m-a-x_-v-a-l-u-e), the resulting `UByte` value represents the same numerical value as this `UShort`. The resulting `UByte` value is represented by the least significant 8 bits of this `UShort` value. kotlin floorDiv floorDiv ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [floorDiv](floor-div) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun floorDiv(other: UByte): UInt ``` ``` fun floorDiv(other: UShort): UInt ``` ``` fun floorDiv(other: UInt): UInt ``` ``` fun floorDiv(other: ULong): ULong ``` Divides this value by the other value, flooring the result to an integer that is closer to negative infinity. For unsigned types, the results of flooring division and truncating division are the same. kotlin toShort toShort ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toShort(): Short ``` Converts this [UShort](index) value to [Short](../-short/index#kotlin.Short). If this value is less than or equals to [Short.MAX\_VALUE](../-short/-m-a-x_-v-a-l-u-e#kotlin.Short.Companion%24MAX_VALUE), the resulting `Short` value represents the same numerical value as this `UShort`. Otherwise the result is negative. The resulting `Short` value has the same binary representation as this `UShort` value. kotlin toULong toULong ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toULong](to-u-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toULong(): ULong ``` Converts this [UShort](index) value to [ULong](../-u-long/index). The resulting `ULong` value represents the same numerical value as this `UShort`. The least significant 16 bits of the resulting `ULong` value are the same as the bits of this `UShort` value, whereas the most significant 48 bits are filled with zeros. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun plus(other: UByte): UInt ``` ``` operator fun plus(other: UShort): UInt ``` ``` operator fun plus(other: UInt): UInt ``` ``` operator fun plus(other: ULong): ULong ``` Adds the other value to this value. kotlin or or == [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / <or> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun or(other: UShort): UShort ``` Performs a bitwise OR operation between the two values. kotlin toUShort toUShort ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShort](index) / [toUShort](to-u-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUShort(): UShort ``` Returns this value. kotlin message message ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [RequiresOptIn](index) / <message> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val message: String ``` message to be reported on usages of API without an explicit opt-in, or empty string for the default message. The default message is: "This declaration is experimental and its usage should be marked with 'Marker' or '@OptIn(Marker::class)'", where `Marker` is the opt-in requirement marker. Property -------- `message` - message to be reported on usages of API without an explicit opt-in, or empty string for the default message. The default message is: "This declaration is experimental and its usage should be marked with 'Marker' or '@OptIn(Marker::class)'", where `Marker` is the opt-in requirement marker. kotlin RequiresOptIn RequiresOptIn ============= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [RequiresOptIn](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) annotation class RequiresOptIn ``` Signals that the annotated annotation class is a marker of an API that requires an explicit opt-in. Call sites of any declaration that is either annotated with such a marker or mentions in its signature any other declaration that requires opt-in should opt in to the API either by using [OptIn](../-opt-in/index), or by being annotated with that marker themselves, effectively causing further propagation of the opt-in requirement. The intended uses of opt-in markers include, but are not limited to the following: * Experimental API for public preview that might change its semantics or affect binary compatibility. * Internal declarations that should not be used outside the declaring library, but are `public` for technical reasons. * Fragile or delicate API that needs a lot of expertise to use and thus require an explicit opt-in. Contagiousness -------------- When a declaration is marked with an opt-in requirement, it is considered to be contagious, meaning that all its uses or mentions in other declarations will require an explicit opt-in. A rule of thumb for propagating is the following: if the marked declaration ceases to exist, only the places with explicit opt-in (or the corresponding warning) will break. This rule does not imply transitivity, e.g. the propagation does not propagate opt-in through inlining, making it the responsibility `inline` function author to mark it properly. ### Type scopes A type is considered requiring opt-in if it is marked with an opt-in marker, or the outer declaration (class or interface) requires opt-in. Any use of any declaration that mentions such type in its signature will require an explicit opt-in, even if it is not used directly on the call site, and even if such declarations do not require opt-in directly. For example, consider the following declarations that are marked with non-propagating opt-in: ``` @UnstableApi class Unstable @OptIn(UnstableApi::class) fun foo(): Unstable = Unstable() @OptIn(UnstableApi::class) fun bar(arg: Unstable = Unstable()) {} @OptIn(UnstableApi::class) fun Unstable?.baz() {} ``` and their respective call sites: ``` fun outerFun() { val s = foo() bar() null.baz() } ``` Even though call sites do not mention `Unstable` type directly, the corresponding opt-in warning or error will be triggered in each call site due to propagation contagiousness. Note that the propagation is not transitive, i.e. calls to `outerFun` itself would not trigger any further opt-in requirements. ### Lexical scopes If a type requires an opt-in, such requirement is propagated to its lexical scope and all its nested declarations. For example, for the following scope: ``` @UnstableApi class Unstable { fun memberFun() = ... class NestedClass { fun nestedFun() = ... } } ``` Any use of `Unstable`, `NestedClass`, or their member functions will require an explicit opt-in. ### Overridden declarations Opt-in markers are also propagated through the inheritance and interface implementation. If the base declaration requires an opt-in, overriding it requires either an explicit opt-in or propagating the opt-in requirement. See also [Kotlin language documentation](../../../../../../docs/opt-in-requirements) for more information. ### Types **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Level](-level/index) Severity of the diagnostic that should be reported on usages which did not explicitly opted into the API either by using [OptIn](../-opt-in/index) or by being annotated with the corresponding marker annotation. ``` enum class Level ``` ### Constructors **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Signals that the annotated annotation class is a marker of an API that requires an explicit opt-in. ``` RequiresOptIn(     message: String = "",     level: Level = Level.ERROR) ``` ### Properties **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <level> specifies how usages of API without an explicit opt-in are reported in code. ``` val level: Level ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <message> message to be reported on usages of API without an explicit opt-in, or empty string for the default message. The default message is: "This declaration is experimental and its usage should be marked with 'Marker' or '@OptIn(Marker::class)'", where `Marker` is the opt-in requirement marker. ``` val message: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [RequiresOptIn](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` RequiresOptIn(     message: String = "",     level: Level = Level.ERROR) ``` Signals that the annotated annotation class is a marker of an API that requires an explicit opt-in. Call sites of any declaration that is either annotated with such a marker or mentions in its signature any other declaration that requires opt-in should opt in to the API either by using [OptIn](../-opt-in/index), or by being annotated with that marker themselves, effectively causing further propagation of the opt-in requirement. The intended uses of opt-in markers include, but are not limited to the following: * Experimental API for public preview that might change its semantics or affect binary compatibility. * Internal declarations that should not be used outside the declaring library, but are `public` for technical reasons. * Fragile or delicate API that needs a lot of expertise to use and thus require an explicit opt-in. Contagiousness -------------- When a declaration is marked with an opt-in requirement, it is considered to be contagious, meaning that all its uses or mentions in other declarations will require an explicit opt-in. A rule of thumb for propagating is the following: if the marked declaration ceases to exist, only the places with explicit opt-in (or the corresponding warning) will break. This rule does not imply transitivity, e.g. the propagation does not propagate opt-in through inlining, making it the responsibility `inline` function author to mark it properly. ### Type scopes A type is considered requiring opt-in if it is marked with an opt-in marker, or the outer declaration (class or interface) requires opt-in. Any use of any declaration that mentions such type in its signature will require an explicit opt-in, even if it is not used directly on the call site, and even if such declarations do not require opt-in directly. For example, consider the following declarations that are marked with non-propagating opt-in: ``` @UnstableApi class Unstable @OptIn(UnstableApi::class) fun foo(): Unstable = Unstable() @OptIn(UnstableApi::class) fun bar(arg: Unstable = Unstable()) {} @OptIn(UnstableApi::class) fun Unstable?.baz() {} ``` and their respective call sites: ``` fun outerFun() { val s = foo() bar() null.baz() } ``` Even though call sites do not mention `Unstable` type directly, the corresponding opt-in warning or error will be triggered in each call site due to propagation contagiousness. Note that the propagation is not transitive, i.e. calls to `outerFun` itself would not trigger any further opt-in requirements. ### Lexical scopes If a type requires an opt-in, such requirement is propagated to its lexical scope and all its nested declarations. For example, for the following scope: ``` @UnstableApi class Unstable { fun memberFun() = ... class NestedClass { fun nestedFun() = ... } } ``` Any use of `Unstable`, `NestedClass`, or their member functions will require an explicit opt-in. ### Overridden declarations Opt-in markers are also propagated through the inheritance and interface implementation. If the base declaration requires an opt-in, overriding it requires either an explicit opt-in or propagating the opt-in requirement. See also [Kotlin language documentation](../../../../../../docs/opt-in-requirements) for more information.
programming_docs
kotlin level level ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [RequiresOptIn](index) / <level> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val level: Level ``` specifies how usages of API without an explicit opt-in are reported in code. Property -------- `level` - specifies how usages of API without an explicit opt-in are reported in code. kotlin Level Level ===== [kotlin-stdlib](../../../../../../../index) / [kotlin](../../index) / [RequiresOptIn](../index) / [Level](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` enum class Level ``` Severity of the diagnostic that should be reported on usages which did not explicitly opted into the API either by using [OptIn](../../-opt-in/index) or by being annotated with the corresponding marker annotation. Enum Values ----------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [WARNING](-w-a-r-n-i-n-g) Specifies that a warning should be reported on incorrect usages of this API. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ERROR](-e-r-r-o-r) Specifies that a compilation error should be reported on incorrect usages of this API. kotlin WARNING WARNING ======= [kotlin-stdlib](../../../../../../../index) / [kotlin](../../index) / [RequiresOptIn](../index) / [Level](index) / [WARNING](-w-a-r-n-i-n-g) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` WARNING ``` Specifies that a warning should be reported on incorrect usages of this API. kotlin ERROR ERROR ===== [kotlin-stdlib](../../../../../../../index) / [kotlin](../../index) / [RequiresOptIn](../index) / [Level](index) / [ERROR](-e-r-r-o-r) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ERROR ``` Specifies that a compilation error should be reported on incorrect usages of this API. kotlin OptionalExpectation OptionalExpectation =================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [OptionalExpectation](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) @ExperimentalMultiplatform annotation class OptionalExpectation ``` Marks an expected annotation class that it isn't required to have actual counterparts in all platforms. This annotation is only applicable to `expect` annotation classes in multi-platform projects and marks that class as "optional". Optional expected class is allowed to have no corresponding actual class on the platform. Optional annotations can only be used to annotate something, not as types in signatures. If an optional annotation has no corresponding actual class on a platform, the annotation entries where it's used are simply erased when compiling code on that platform. Note: this annotation is experimental, see [ExperimentalMultiplatform](../-experimental-multiplatform/index) on how to opt-in for it. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Marks an expected annotation class that it isn't required to have actual counterparts in all platforms. ``` OptionalExpectation() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [OptionalExpectation](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` OptionalExpectation() ``` Marks an expected annotation class that it isn't required to have actual counterparts in all platforms. This annotation is only applicable to `expect` annotation classes in multi-platform projects and marks that class as "optional". Optional expected class is allowed to have no corresponding actual class on the platform. Optional annotations can only be used to annotate something, not as types in signatures. If an optional annotation has no corresponding actual class on a platform, the annotation entries where it's used are simply erased when compiling code on that platform. Note: this annotation is experimental, see [ExperimentalMultiplatform](../-experimental-multiplatform/index) on how to opt-in for it. kotlin Error Error ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Error](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class Error : Throwable ``` **Platform and version requirements:** JVM (1.1) ``` typealias Error = Error ``` Constructors ------------ **Platform and version requirements:** JS (1.0), Native (1.0) #### [<init>](-init-) ``` <init>() ``` ``` <init>(message: String?) ``` ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` Inherited Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTrace](../-throwable/get-stack-trace) Returns an array of stack trace strings representing the stack trace pertaining to this throwable. ``` fun getStackTrace(): Array<String> ``` **Platform and version requirements:** Native (1.3) #### [printStackTrace](../-throwable/print-stack-trace) Prints the [detailed description](../stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the standard output. ``` fun printStackTrace() ``` **Platform and version requirements:** Native (1.3) #### [toString](../-throwable/to-string) Returns the short description of this throwable consisting of the exception class name (fully qualified if possible) followed by the exception message if it is not null. ``` open fun toString(): String ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](../../kotlin.native/get-stack-trace-addresses) Returns a list of stack trace addresses representing the stack trace pertaining to this throwable. ``` fun Throwable.getStackTraceAddresses(): List<Long> ``` Inheritors ---------- #### [AssertionError](../-assertion-error/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class AssertionError : Error ``` **Platform and version requirements:** JVM (1.1) ``` typealias AssertionError = AssertionError ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [NotImplementedError](../-not-implemented-error/index) An exception is thrown to indicate that a method body remains to be implemented. ``` class NotImplementedError : Error ``` **Platform and version requirements:** Native (1.3) #### [OutOfMemoryError](../-out-of-memory-error/index) ``` open class OutOfMemoryError : Error ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Error](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` kotlin ExperimentalMultiplatform ExperimentalMultiplatform ========================= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExperimentalMultiplatform](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPEALIAS]) annotation class ExperimentalMultiplatform ``` The experimental multiplatform support API marker. Any usage of a declaration annotated with `@ExperimentalMultiplatform` must be accepted either by annotating that usage with the [OptIn](../-opt-in/index) annotation, e.g. `@OptIn(ExperimentalMultiplatform::class)`, or by using the compiler argument `-opt-in=kotlin.ExperimentalMultiplatform`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) The experimental multiplatform support API marker. ``` ExperimentalMultiplatform() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExperimentalMultiplatform](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ExperimentalMultiplatform() ``` The experimental multiplatform support API marker. Any usage of a declaration annotated with `@ExperimentalMultiplatform` must be accepted either by annotating that usage with the [OptIn](../-opt-in/index) annotation, e.g. `@OptIn(ExperimentalMultiplatform::class)`, or by using the compiler argument `-opt-in=kotlin.ExperimentalMultiplatform`. kotlin PublishedApi PublishedApi ============ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [PublishedApi](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY]) annotation class PublishedApi ``` When applied to a class or a member with internal visibility allows to use it from public inline functions and makes it effectively public. Public inline functions cannot use non-public API, since if they are inlined, those non-public API references would violate access restrictions at a call site (https://kotlinlang.org/docs/reference/inline-functions.html#public-inline-restrictions). To overcome this restriction an `internal` declaration can be annotated with the `@PublishedApi` annotation: * this allows to call that declaration from public inline functions; * the declaration becomes effectively public, and this should be considered with respect to binary compatibility maintaining. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) When applied to a class or a member with internal visibility allows to use it from public inline functions and makes it effectively public. ``` <init>() ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotationClass](../../kotlin.jvm/annotation-class) Returns a [KClass](../../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance corresponding to the annotation type of this annotation. ``` val <T : Annotation> T.annotationClass: KClass<out T> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [PublishedApi](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>() ``` When applied to a class or a member with internal visibility allows to use it from public inline functions and makes it effectively public. Public inline functions cannot use non-public API, since if they are inlined, those non-public API references would violate access restrictions at a call site (https://kotlinlang.org/docs/reference/inline-functions.html#public-inline-restrictions). To overcome this restriction an `internal` declaration can be annotated with the `@PublishedApi` annotation: * this allows to call that declaration from public inline functions; * the declaration becomes effectively public, and this should be considered with respect to binary compatibility maintaining. kotlin DeepRecursiveScope DeepRecursiveScope ================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeepRecursiveScope](index) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` sealed class DeepRecursiveScope<T, R> ``` A scope class for [DeepRecursiveFunction](../-deep-recursive-function/index) function declaration that defines [callRecursive](call-recursive) methods to recursively call this function or another [DeepRecursiveFunction](../-deep-recursive-function/index) putting the call activation frame on the heap. Parameters ---------- `T` - function parameter type. `R` - function result type. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [callRecursive](call-recursive) Makes recursive call to this [DeepRecursiveFunction](../-deep-recursive-function/index) function putting the call activation frame on the heap, as opposed to the actual call stack that is used by a regular recursive call. ``` abstract suspend fun callRecursive(value: T): R ``` Makes call to the specified [DeepRecursiveFunction](../-deep-recursive-function/index) function putting the call activation frame on the heap, as opposed to the actual call stack that is used by a regular call. ``` abstract suspend fun <U, S> DeepRecursiveFunction<U, S>.callRecursive(     value: U ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <invoke> ``` operator fun DeepRecursiveFunction<*, *>.invoke(     value: Any? ): Nothing ``` kotlin invoke invoke ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeepRecursiveScope](index) / <invoke> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun DeepRecursiveFunction<*, *>.invoke(     value: Any? ): Nothing ``` **Deprecated:** DeprecationLevel.ERROR kotlin callRecursive callRecursive ============= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeepRecursiveScope](index) / [callRecursive](call-recursive) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract suspend fun callRecursive(value: T): R ``` Makes recursive call to this [DeepRecursiveFunction](../-deep-recursive-function/index) function putting the call activation frame on the heap, as opposed to the actual call stack that is used by a regular recursive call. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract suspend fun <U, S> DeepRecursiveFunction<U, S>.callRecursive(     value: U ): S ``` Makes call to the specified [DeepRecursiveFunction](../-deep-recursive-function/index) function putting the call activation frame on the heap, as opposed to the actual call stack that is used by a regular call. kotlin ArithmeticException ArithmeticException =================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ArithmeticException](index) **Platform and version requirements:** JS (1.3), Native (1.3) ``` open class ArithmeticException : RuntimeException ``` **Platform and version requirements:** JVM (1.3) ``` typealias ArithmeticException = ArithmeticException ``` Constructors ------------ **Platform and version requirements:** JS (1.0), Native (1.0) #### [<init>](-init-) ``` <init>() ``` ``` <init>(message: String?) ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](../../kotlin.native/get-stack-trace-addresses) Returns a list of stack trace addresses representing the stack trace pertaining to this throwable. ``` fun Throwable.getStackTraceAddresses(): List<Long> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ArithmeticException](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` kotlin message message ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Deprecated](index) / <message> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val message: String ``` The message explaining the deprecation and recommending an alternative API to use. Property -------- `message` - The message explaining the deprecation and recommending an alternative API to use. kotlin Deprecated Deprecated ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Deprecated](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.TYPEALIAS]) annotation class Deprecated ``` Marks the annotated declaration as deprecated. A deprecated API element is not recommended to use, typically because it's being phased out or a better alternative exists. To help removing deprecated API gradually, the property [level](level#kotlin.Deprecated%24level) could be used. Usually a gradual phase-out goes through the "warning", then "error", then "hidden" or "removed" stages: * First and by default, [DeprecationLevel.WARNING](../-deprecation-level/-w-a-r-n-i-n-g#kotlin.DeprecationLevel.WARNING) is used to notify API consumers, but not to break their compilation or runtime usages. * Then, some time later the deprecation level is raised to [DeprecationLevel.ERROR](../-deprecation-level/-e-r-r-o-r#kotlin.DeprecationLevel.ERROR), so that no new Kotlin code can be compiled using the deprecated API. * Finally, the API is either removed entirely, or hidden ([DeprecationLevel.HIDDEN](../-deprecation-level/-h-i-d-d-e-n#kotlin.DeprecationLevel.HIDDEN)) from code, so its usages look like unresolved references, while the API remains in the compiled code preserving binary compatibility with previously compiled code. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Marks the annotated declaration as deprecated. ``` <init>(     message: String,     replaceWith: ReplaceWith = ReplaceWith(""),     level: DeprecationLevel = DeprecationLevel.WARNING) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <level> Specifies how the deprecated element usages are reported in code. See the [DeprecationLevel](../-deprecation-level/index#kotlin.DeprecationLevel) enum for the possible values. ``` val level: DeprecationLevel ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <message> The message explaining the deprecation and recommending an alternative API to use. ``` val message: String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceWith](replace-with) If present, specifies a code fragment which should be used as a replacement for the deprecated API usage. ``` val replaceWith: ReplaceWith ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotationClass](../../kotlin.jvm/annotation-class) Returns a [KClass](../../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance corresponding to the annotation type of this annotation. ``` val <T : Annotation> T.annotationClass: KClass<out T> ``` kotlin replaceWith replaceWith =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Deprecated](index) / [replaceWith](replace-with) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val replaceWith: ReplaceWith ``` If present, specifies a code fragment which should be used as a replacement for the deprecated API usage. Property -------- `replaceWith` - If present, specifies a code fragment which should be used as a replacement for the deprecated API usage. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Deprecated](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>(     message: String,     replaceWith: ReplaceWith = ReplaceWith(""),     level: DeprecationLevel = DeprecationLevel.WARNING) ``` Marks the annotated declaration as deprecated. A deprecated API element is not recommended to use, typically because it's being phased out or a better alternative exists. To help removing deprecated API gradually, the property [level](level#kotlin.Deprecated%24level) could be used. Usually a gradual phase-out goes through the "warning", then "error", then "hidden" or "removed" stages: * First and by default, [DeprecationLevel.WARNING](../-deprecation-level/-w-a-r-n-i-n-g#kotlin.DeprecationLevel.WARNING) is used to notify API consumers, but not to break their compilation or runtime usages. * Then, some time later the deprecation level is raised to [DeprecationLevel.ERROR](../-deprecation-level/-e-r-r-o-r#kotlin.DeprecationLevel.ERROR), so that no new Kotlin code can be compiled using the deprecated API. * Finally, the API is either removed entirely, or hidden ([DeprecationLevel.HIDDEN](../-deprecation-level/-h-i-d-d-e-n#kotlin.DeprecationLevel.HIDDEN)) from code, so its usages look like unresolved references, while the API remains in the compiled code preserving binary compatibility with previously compiled code.
programming_docs
kotlin level level ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Deprecated](index) / <level> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val level: DeprecationLevel ``` Specifies how the deprecated element usages are reported in code. See the [DeprecationLevel](../-deprecation-level/index#kotlin.DeprecationLevel) enum for the possible values. Property -------- `level` - Specifies how the deprecated element usages are reported in code. See the [DeprecationLevel](../-deprecation-level/index#kotlin.DeprecationLevel) enum for the possible values. kotlin SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [SIZE\_BITS](-s-i-z-e_-b-i-t-s) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` const val SIZE_BITS: Int ``` The number of bits used to represent an instance of Long in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toInt(): Int ``` Converts this [Long](index#kotlin.Long) value to [Int](../-int/index#kotlin.Int). If this value is in [Int.MIN\_VALUE](../-int/-m-i-n_-v-a-l-u-e#kotlin.Int.Companion%24MIN_VALUE)..[Int.MAX\_VALUE](../-int/-m-a-x_-v-a-l-u-e#kotlin.Int.Companion%24MAX_VALUE), the resulting `Int` value represents the same numerical value as this `Long`. The resulting `Int` value is represented by the least significant 32 bits of this `Long` value. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toByte(): Byte ``` Converts this [Long](index#kotlin.Long) value to [Byte](../-byte/index#kotlin.Byte). If this value is in [Byte.MIN\_VALUE](../-byte/-m-i-n_-v-a-l-u-e#kotlin.Byte.Companion%24MIN_VALUE)..[Byte.MAX\_VALUE](../-byte/-m-a-x_-v-a-l-u-e#kotlin.Byte.Companion%24MAX_VALUE), the resulting `Byte` value represents the same numerical value as this `Long`. The resulting `Byte` value is represented by the least significant 8 bits of this `Long` value. kotlin unaryPlus unaryPlus ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [unaryPlus](unary-plus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryPlus(): Long ``` Returns this value. kotlin shr shr === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <shr> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun shr(bitCount: Int): Long ``` Shifts this value right by the [bitCount](shr#kotlin.Long%24shr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with copies of the sign bit. Note that only the six lowest-order bits of the [bitCount](shr#kotlin.Long%24shr(kotlin.Int)/bitCount) are used as the shift distance. The shift distance actually used is therefore always in the range `0..63`. kotlin Long Long ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Long : Number, Comparable<Long> ``` ##### For Common, JVM, JS Represents a 64-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type `long`. ##### For Native Represents a 64-bit signed integer. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <and> Performs a bitwise AND operation between the two values. ``` infix fun and(other: Long): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareTo](compare-to) Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other. ``` operator fun compareTo(other: Byte): Int ``` ``` operator fun compareTo(other: Short): Int ``` ``` operator fun compareTo(other: Int): Int ``` ``` operator fun compareTo(other: Long): Int ``` ``` operator fun compareTo(other: Float): Int ``` ``` operator fun compareTo(other: Double): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <dec> Returns this value decremented by one. ``` operator fun dec(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <div> Divides this value by the other value, truncating the result to an integer that is closer to zero. ``` operator fun div(other: Byte): Long ``` ``` operator fun div(other: Short): Long ``` ``` operator fun div(other: Int): Long ``` ``` operator fun div(other: Long): Long ``` Divides this value by the other value. ``` operator fun div(other: Float): Float ``` ``` operator fun div(other: Double): Double ``` #### <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Long): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: ``` fun equals(other: Any?): Boolean ``` **Platform and version requirements:** Native (1.3) #### [hashCode](hash-code) Returns a hash code value for the object. The general contract of `hashCode` is: ``` fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inc> Returns this value incremented by one. ``` operator fun inc(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inv> Inverts the bits in this value. ``` fun inv(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <minus> Subtracts the other value from this value. ``` operator fun minus(other: Byte): Long ``` ``` operator fun minus(other: Short): Long ``` ``` operator fun minus(other: Int): Long ``` ``` operator fun minus(other: Long): Long ``` ``` operator fun minus(other: Float): Float ``` ``` operator fun minus(other: Double): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <or> Performs a bitwise OR operation between the two values. ``` infix fun or(other: Long): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Adds the other value to this value. ``` operator fun plus(other: Byte): Long ``` ``` operator fun plus(other: Short): Long ``` ``` operator fun plus(other: Int): Long ``` ``` operator fun plus(other: Long): Long ``` ``` operator fun plus(other: Float): Float ``` ``` operator fun plus(other: Double): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](range-to) Creates a range from this value to the specified [other](range-to#kotlin.Long%24rangeTo(kotlin.Byte)/other) value. ``` operator fun rangeTo(other: Byte): LongRange ``` ``` operator fun rangeTo(other: Short): LongRange ``` ``` operator fun rangeTo(other: Int): LongRange ``` ``` operator fun rangeTo(other: Long): LongRange ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [rangeUntil](range-until) Creates a range from this value up to but excluding the specified [other](range-until#kotlin.Long%24rangeUntil(kotlin.Byte)/other) value. ``` operator fun rangeUntil(other: Byte): LongRange ``` ``` operator fun rangeUntil(other: Short): LongRange ``` ``` operator fun rangeUntil(other: Int): LongRange ``` ``` operator fun rangeUntil(other: Long): LongRange ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### <rem> Calculates the remainder of truncating division of this value by the other value. ``` operator fun rem(other: Byte): Long ``` ``` operator fun rem(other: Short): Long ``` ``` operator fun rem(other: Int): Long ``` ``` operator fun rem(other: Long): Long ``` ``` operator fun rem(other: Float): Float ``` ``` operator fun rem(other: Double): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <shl> Shifts this value left by the [bitCount](shl#kotlin.Long%24shl(kotlin.Int)/bitCount) number of bits. ``` infix fun shl(bitCount: Int): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <shr> Shifts this value right by the [bitCount](shr#kotlin.Long%24shr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with copies of the sign bit. ``` infix fun shr(bitCount: Int): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <times> Multiplies this value by the other value. ``` operator fun times(other: Byte): Long ``` ``` operator fun times(other: Short): Long ``` ``` operator fun times(other: Int): Long ``` ``` operator fun times(other: Long): Long ``` ``` operator fun times(other: Float): Float ``` ``` operator fun times(other: Double): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Converts this [Long](index#kotlin.Long) value to [Byte](../-byte/index#kotlin.Byte). ``` fun toByte(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toChar](to-char) Converts this [Long](index#kotlin.Long) value to [Char](../-char/index#kotlin.Char). ``` fun toChar(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDouble](to-double) Converts this [Long](index#kotlin.Long) value to [Double](../-double/index#kotlin.Double). ``` fun toDouble(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloat](to-float) Converts this [Long](index#kotlin.Long) value to [Float](../-float/index#kotlin.Float). ``` fun toFloat(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toInt](to-int) Converts this [Long](index#kotlin.Long) value to [Int](../-int/index#kotlin.Int). ``` fun toInt(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLong](to-long) Returns this value. ``` fun toLong(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShort](to-short) Converts this [Long](index#kotlin.Long) value to [Short](../-short/index#kotlin.Short). ``` fun toShort(): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns a string representation of the object. ``` fun toString(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unaryMinus](unary-minus) Returns the negative of this value. ``` operator fun unaryMinus(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unaryPlus](unary-plus) Returns this value. ``` operator fun unaryPlus(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <ushr> Shifts this value right by the [bitCount](ushr#kotlin.Long%24ushr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with zeros. ``` infix fun ushr(bitCount: Int): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <xor> Performs a bitwise XOR operation between the two values. ``` infix fun xor(other: Long): Long ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MAX\_VALUE](-m-a-x_-v-a-l-u-e) A constant holding the maximum value an instance of Long can have. ``` const val MAX_VALUE: Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MIN\_VALUE](-m-i-n_-v-a-l-u-e) A constant holding the minimum value an instance of Long can have. ``` const val MIN_VALUE: Long ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [SIZE\_BITS](-s-i-z-e_-b-i-t-s) The number of bits used to represent an instance of Long in a binary form. ``` const val SIZE_BITS: Int ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) The number of bytes used to represent an instance of Long in a binary form. ``` const val SIZE_BYTES: Int ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [days](../../kotlin.time/days) Returns a [Duration](../../kotlin.time/-duration/index) equal to this [Long](index#kotlin.Long) number of days. ``` val Long.days: Duration ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [hours](../../kotlin.time/hours) Returns a [Duration](../../kotlin.time/-duration/index) equal to this [Long](index#kotlin.Long) number of hours. ``` val Long.hours: Duration ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [microseconds](../../kotlin.time/microseconds) Returns a [Duration](../../kotlin.time/-duration/index) equal to this [Long](index#kotlin.Long) number of microseconds. ``` val Long.microseconds: Duration ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [milliseconds](../../kotlin.time/milliseconds) Returns a [Duration](../../kotlin.time/-duration/index) equal to this [Long](index#kotlin.Long) number of milliseconds. ``` val Long.milliseconds: Duration ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [minutes](../../kotlin.time/minutes) Returns a [Duration](../../kotlin.time/-duration/index) equal to this [Long](index#kotlin.Long) number of minutes. ``` val Long.minutes: Duration ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [nanoseconds](../../kotlin.time/nanoseconds) Returns a [Duration](../../kotlin.time/-duration/index) equal to this [Long](index#kotlin.Long) number of nanoseconds. ``` val Long.nanoseconds: Duration ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [seconds](../../kotlin.time/seconds) Returns a [Duration](../../kotlin.time/-duration/index) equal to this [Long](index#kotlin.Long) number of seconds. ``` val Long.seconds: Duration ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceAtLeast](../../kotlin.ranges/coerce-at-least) Ensures that this value is not less than the specified [minimumValue](../../kotlin.ranges/coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.Long,%20kotlin.Long)/minimumValue). ``` fun Long.coerceAtLeast(minimumValue: Long): Long ``` ``` fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceAtMost](../../kotlin.ranges/coerce-at-most) Ensures that this value is not greater than the specified [maximumValue](../../kotlin.ranges/coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.Long,%20kotlin.Long)/maximumValue). ``` fun Long.coerceAtMost(maximumValue: Long): Long ``` ``` fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceIn](../../kotlin.ranges/coerce-in) Ensures that this value lies in the specified range [minimumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.Long,%20kotlin.Long,%20kotlin.Long)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.Long,%20kotlin.Long,%20kotlin.Long)/maximumValue). ``` fun Long.coerceIn(     minimumValue: Long,     maximumValue: Long ): Long ``` ``` fun <T : Comparable<T>> T.coerceIn(     minimumValue: T?,     maximumValue: T? ): T ``` Ensures that this value lies in the specified [range](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.Long,%20kotlin.ranges.ClosedRange((kotlin.Long)))/range). ``` fun Long.coerceIn(range: ClosedRange<Long>): Long ``` ``` fun <T : Comparable<T>> T.coerceIn(     range: ClosedFloatingPointRange<T> ): T ``` ``` fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [compareTo](../compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other) object, a negative number if it's less than [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other), or a positive number if it's greater than [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other). ``` infix fun <T> Comparable<T>.compareTo(other: T): Int ``` **Platform and version requirements:** Native (1.3) #### [convert](../../kotlinx.cinterop/convert) ``` fun <R : Any> Long.convert(): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [downTo](../../kotlin.ranges/down-to) Returns a progression from this value down to the specified [to](../../kotlin.ranges/down-to#kotlin.ranges%24downTo(kotlin.Long,%20kotlin.Byte)/to) value with the step -1. ``` infix fun Long.downTo(to: Byte): LongProgression ``` ``` infix fun Long.downTo(to: Int): LongProgression ``` ``` infix fun Long.downTo(to: Long): LongProgression ``` ``` infix fun Long.downTo(to: Short): LongProgression ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [floorDiv](../floor-div) Divides this value by the other value, flooring the result to an integer that is closer to negative infinity. ``` fun Long.floorDiv(other: Byte): Long ``` ``` fun Long.floorDiv(other: Short): Long ``` ``` fun Long.floorDiv(other: Int): Long ``` ``` fun Long.floorDiv(other: Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [mod](../mod) Calculates the remainder of flooring division of this value by the other value. ``` fun Long.mod(other: Byte): Byte ``` ``` fun Long.mod(other: Short): Short ``` ``` fun Long.mod(other: Int): Int ``` ``` fun Long.mod(other: Long): Long ``` **Platform and version requirements:** Native (1.3) #### [narrow](../../kotlinx.cinterop/narrow) ``` fun <R : Number> Number.narrow(): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](../../kotlin.ranges/range-to) Creates a range from this [Comparable](../-comparable/index#kotlin.Comparable) value to the specified [that](../../kotlin.ranges/range-to#kotlin.ranges%24rangeTo(kotlin.ranges.rangeTo.T,%20kotlin.ranges.rangeTo.T)/that) value. ``` operator fun <T : Comparable<T>> T.rangeTo(     that: T ): ClosedRange<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [rangeUntil](../../kotlin.ranges/range-until) Creates an open-ended range from this [Comparable](../-comparable/index#kotlin.Comparable) value to the specified [that](../../kotlin.ranges/range-until#kotlin.ranges%24rangeUntil(kotlin.ranges.rangeUntil.T,%20kotlin.ranges.rangeUntil.T)/that) value. ``` operator fun <T : Comparable<T>> T.rangeUntil(     that: T ): OpenEndRange<T> ``` **Platform and version requirements:** Native (1.3) #### [signExtend](../../kotlinx.cinterop/sign-extend) ``` fun <R : Number> Number.signExtend(): R ``` **Platform and version requirements:** JVM (1.2) #### [toBigDecimal](../to-big-decimal) Returns the value of this [Long](index#kotlin.Long) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). ``` fun Long.toBigDecimal(): BigDecimal ``` ``` fun Long.toBigDecimal(mathContext: MathContext): BigDecimal ``` **Platform and version requirements:** JVM (1.2) #### [toBigInteger](../to-big-integer) Returns the value of this [Long](index#kotlin.Long) number as a [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html). ``` fun Long.toBigInteger(): BigInteger ``` **Platform and version requirements:** Native (1.3) #### [toCPointer](../../kotlinx.cinterop/to-c-pointer) ``` fun <T : CPointed> Long.toCPointer(): CPointer<T>? ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [toDuration](../../kotlin.time/to-duration) Returns a [Duration](../../kotlin.time/-duration/index) equal to this [Long](index#kotlin.Long) number of the specified [unit](../../kotlin.time/to-duration#kotlin.time%24toDuration(kotlin.Long,%20kotlin.time.DurationUnit)/unit). ``` fun Long.toDuration(unit: DurationUnit): Duration ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUByte](../to-u-byte) Converts this [Long](index#kotlin.Long) value to [UByte](../-u-byte/index). ``` fun Long.toUByte(): UByte ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUInt](../to-u-int) Converts this [Long](index#kotlin.Long) value to [UInt](../-u-int/index). ``` fun Long.toUInt(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULong](../to-u-long) Converts this [Long](index#kotlin.Long) value to [ULong](../-u-long/index). ``` fun Long.toULong(): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUShort](../to-u-short) Converts this [Long](index#kotlin.Long) value to [UShort](../-u-short/index). ``` fun Long.toUShort(): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [until](../../kotlin.ranges/until) Returns a range from this value up to but excluding the specified [to](../../kotlin.ranges/until#kotlin.ranges%24until(kotlin.Long,%20kotlin.Byte)/to) value. ``` infix fun Long.until(to: Byte): LongRange ``` ``` infix fun Long.until(to: Int): LongRange ``` ``` infix fun Long.until(to: Long): LongRange ``` ``` infix fun Long.until(to: Short): LongRange ```
programming_docs
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` const val SIZE_BYTES: Int ``` The number of bytes used to represent an instance of Long in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [MIN\_VALUE](-m-i-n_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MIN_VALUE: Long ``` A constant holding the minimum value an instance of Long can have. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toLong(): Long ``` Returns this value. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [MAX\_VALUE](-m-a-x_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MAX_VALUE: Long ``` A constant holding the maximum value an instance of Long can have. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun compareTo(other: Byte): Int ``` ``` operator fun compareTo(other: Short): Int ``` ``` operator fun compareTo(other: Int): Int ``` ``` operator fun compareTo(other: Long): Int ``` ``` operator fun compareTo(other: Float): Int ``` ``` operator fun compareTo(other: Double): Int ``` Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other. kotlin rangeTo rangeTo ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [rangeTo](range-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rangeTo(other: Byte): LongRange ``` ``` operator fun rangeTo(other: Short): LongRange ``` ``` operator fun rangeTo(other: Int): LongRange ``` ``` operator fun rangeTo(other: Long): LongRange ``` Creates a range from this value to the specified [other](range-to#kotlin.Long%24rangeTo(kotlin.Byte)/other) value. kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <rem> **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun rem(other: Byte): Long ``` ``` operator fun rem(other: Short): Long ``` ``` operator fun rem(other: Int): Long ``` ``` operator fun rem(other: Long): Long ``` ``` operator fun rem(other: Float): Float ``` ``` operator fun rem(other: Double): Double ``` Calculates the remainder of truncating division of this value by the other value. The result is either zero or has the same sign as the *dividend* and has the absolute value less than the absolute value of the divisor. kotlin shl shl === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <shl> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun shl(bitCount: Int): Long ``` Shifts this value left by the [bitCount](shl#kotlin.Long%24shl(kotlin.Int)/bitCount) number of bits. Note that only the six lowest-order bits of the [bitCount](shl#kotlin.Long%24shl(kotlin.Int)/bitCount) are used as the shift distance. The shift distance actually used is therefore always in the range `0..63`. kotlin rangeUntil rangeUntil ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [rangeUntil](range-until) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Byte ): LongRange ``` ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Short ): LongRange ``` ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Int ): LongRange ``` ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Long ): LongRange ``` Creates a range from this value up to but excluding the specified [other](range-until#kotlin.Long%24rangeUntil(kotlin.Byte)/other) value. If the [other](range-until#kotlin.Long%24rangeUntil(kotlin.Byte)/other) value is less than or equal to `this` value, then the returned range is empty. kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <div> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: Byte): Long ``` ``` operator fun div(other: Short): Long ``` ``` operator fun div(other: Int): Long ``` ``` operator fun div(other: Long): Long ``` Divides this value by the other value, truncating the result to an integer that is closer to zero. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: Float): Float ``` ``` operator fun div(other: Double): Double ``` Divides this value by the other value. kotlin toDouble toDouble ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toDouble(): Double ``` Converts this [Long](index#kotlin.Long) value to [Double](../-double/index#kotlin.Double). The resulting value is the closest `Double` to this `Long` value. In case when this `Long` value is exactly between two `Double`s, the one with zero at least significant bit of mantissa is selected. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun dec(): Long ``` Returns this value decremented by one. ``` fun main(args: Array<String>) { //sampleStart val a = 3 val b = a.dec() println(a) // 3 println(b) // 2 var x = 3 val y = x-- println(x) // 2 println(y) // 3 val z = --x println(x) // 1 println(z) // 1 //sampleEnd } ``` kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [hashCode](hash-code) **Platform and version requirements:** Native (1.3) ``` fun hashCode(): Int ``` Returns a hash code value for the object. The general contract of `hashCode` is: * Whenever it is invoked on the same object more than once, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. * If two objects are equal according to the `equals()` method, then calling the `hashCode` method on each of the two objects must produce the same integer result. kotlin and and === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <and> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun and(other: Long): Long ``` Performs a bitwise AND operation between the two values. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun inc(): Long ``` Returns this value incremented by one. ``` fun main(args: Array<String>) { //sampleStart val a = 3 val b = a.inc() println(a) // 3 println(b) // 4 var x = 3 val y = x++ println(x) // 4 println(y) // 3 val z = ++x println(x) // 5 println(z) // 5 //sampleEnd } ``` kotlin inv inv === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <inv> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun inv(): Long ``` Inverts the bits in this value. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toString(): String ``` Returns a string representation of the object. kotlin unaryMinus unaryMinus ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [unaryMinus](unary-minus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryMinus(): Long ``` Returns the negative of this value. kotlin xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <xor> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun xor(other: Long): Long ``` Performs a bitwise XOR operation between the two values. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun equals(other: Any?): Boolean ``` Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: * Reflexive: for any non-null value `x`, `x.equals(x)` should return true. * Symmetric: for any non-null values `x` and `y`, `x.equals(y)` should return true if and only if `y.equals(x)` returns true. * Transitive: for any non-null values `x`, `y`, and `z`, if `x.equals(y)` returns true and `y.equals(z)` returns true, then `x.equals(z)` should return true. * Consistent: for any non-null values `x` and `y`, multiple invocations of `x.equals(y)` consistently return true or consistently return false, provided no information used in `equals` comparisons on the objects is modified. * Never equal to null: for any non-null value `x`, `x.equals(null)` should return false. Read more about [equality](../../../../../../docs/equality) in Kotlin. **Platform and version requirements:** Native (1.3) ``` fun equals(other: Long): Boolean ``` kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <times> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun times(other: Byte): Long ``` ``` operator fun times(other: Short): Long ``` ``` operator fun times(other: Int): Long ``` ``` operator fun times(other: Long): Long ``` ``` operator fun times(other: Float): Float ``` ``` operator fun times(other: Double): Double ``` Multiplies this value by the other value. kotlin toFloat toFloat ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toFloat(): Float ``` Converts this [Long](index#kotlin.Long) value to [Float](../-float/index#kotlin.Float). The resulting value is the closest `Float` to this `Long` value. In case when this `Long` value is exactly between two `Float`s, the one with zero at least significant bit of mantissa is selected. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: Byte): Long ``` ``` operator fun minus(other: Short): Long ``` ``` operator fun minus(other: Int): Long ``` ``` operator fun minus(other: Long): Long ``` ``` operator fun minus(other: Float): Float ``` ``` operator fun minus(other: Double): Double ``` Subtracts the other value from this value. kotlin ushr ushr ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <ushr> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun ushr(bitCount: Int): Long ``` Shifts this value right by the [bitCount](ushr#kotlin.Long%24ushr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with zeros. Note that only the six lowest-order bits of the [bitCount](ushr#kotlin.Long%24ushr(kotlin.Int)/bitCount) are used as the shift distance. The shift distance actually used is therefore always in the range `0..63`. kotlin toShort toShort ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toShort(): Short ``` Converts this [Long](index#kotlin.Long) value to [Short](../-short/index#kotlin.Short). If this value is in [Short.MIN\_VALUE](../-short/-m-i-n_-v-a-l-u-e#kotlin.Short.Companion%24MIN_VALUE)..[Short.MAX\_VALUE](../-short/-m-a-x_-v-a-l-u-e#kotlin.Short.Companion%24MAX_VALUE), the resulting `Short` value represents the same numerical value as this `Long`. The resulting `Short` value is represented by the least significant 16 bits of this `Long` value. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun plus(other: Byte): Long ``` ``` operator fun plus(other: Short): Long ``` ``` operator fun plus(other: Int): Long ``` ``` operator fun plus(other: Long): Long ``` ``` operator fun plus(other: Float): Float ``` ``` operator fun plus(other: Double): Double ``` Adds the other value to this value. kotlin or or == [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / <or> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun or(other: Long): Long ``` Performs a bitwise OR operation between the two values. kotlin toChar toChar ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Long](index) / [toChar](to-char) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.5") fun toChar(): Char ``` **Deprecated:** Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. Converts this [Long](index#kotlin.Long) value to [Char](../-char/index#kotlin.Char). If this value is in the range of `Char` codes `Char.MIN_VALUE..Char.MAX_VALUE`, the resulting `Char` code is equal to this value. The resulting `Char` code is represented by the least significant 16 bits of this `Long` value. kotlin TypeCastException TypeCastException ================= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [TypeCastException](index) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` open class TypeCastException : ClassCastException ``` Constructors ------------ **Platform and version requirements:** JVM (1.0), Native (1.0) #### [<init>](-init-) ``` <init>() ``` ``` <init>(message: String?) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [stackTrace](../stack-trace) Returns an array of stack trace elements representing the stack trace pertaining to this throwable. ``` val Throwable.stackTrace: Array<StackTraceElement> ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](../../kotlin.native/get-stack-trace-addresses) Returns a list of stack trace addresses representing the stack trace pertaining to this throwable. ``` fun Throwable.getStackTraceAddresses(): List<Long> ``` **Platform and version requirements:** JVM (1.0) #### [printStackTrace](../print-stack-trace) Prints the [detailed description](../stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [writer](../print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintWriter)/writer). ``` fun Throwable.printStackTrace(writer: PrintWriter) ``` Prints the [detailed description](../stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [stream](../print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintStream)/stream). ``` fun Throwable.printStackTrace(stream: PrintStream) ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [TypeCastException](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(element: ULong): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val size: Int ``` Returns the number of elements in the array. kotlin ULongArray ULongArray ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes inline class ULongArray :      Collection<ULong> ``` Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, with all elements initialized to zero. ``` ULongArray(size: Int) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> Returns the number of elements in the array. ``` val size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> ``` fun contains(element: ULong): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) ``` fun containsAll(elements: Collection<ULong>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the array element at the given [index](get#kotlin.ULongArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) ``` fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Creates an iterator over the elements of the array. ``` operator fun iterator(): Iterator<ULong> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.ULongArray%24set(kotlin.Int,%20kotlin.ULong)/index) to the given [value](set#kotlin.ULongArray%24set(kotlin.Int,%20kotlin.ULong)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: ULong) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val ULongArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val ULongArray.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../../kotlin.collections/all) Returns `true` if all elements match the given [predicate](../../kotlin.collections/all#kotlin.collections%24all(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.all(predicate: (ULong) -> Boolean): Boolean ``` ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../../kotlin.collections/any) Returns `true` if array has at least one element. ``` fun ULongArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.any(predicate: (ULong) -> Boolean): Boolean ``` ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Returns this collection as an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asLongArray](../../kotlin.collections/as-long-array) Returns an array of type [LongArray](../-long-array/index#kotlin.LongArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun ULongArray.asLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.collections/as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../../kotlin.collections/associate) Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../../kotlin.collections/associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../../kotlin.collections/associate-by) Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../../kotlin.collections/associate-by-to) Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../../kotlin.collections/associate-to) Populates and returns the [destination](../../kotlin.collections/associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../../kotlin.collections/associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../../kotlin.collections/associate-with) Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) where keys are elements from the given array and values are produced by the [valueSelector](../../kotlin.collections/associate-with#kotlin.collections%24associateWith(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> ULongArray.associateWith(     valueSelector: (ULong) -> V ): Map<ULong, V> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../../kotlin.collections/associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.ULongArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given array, where key is the element itself and value is provided by the [valueSelector](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.ULongArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in ULong, in V>> ULongArray.associateWithTo(     destination: M,     valueSelector: (ULong) -> V ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.3) #### [binarySearch](../../kotlin.collections/binary-search) Searches the array or the range of the array for the provided [element](../../kotlin.collections/binary-search#kotlin.collections%24binarySearch(kotlin.ULongArray,%20kotlin.ULong,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun ULongArray.binarySearch(     element: ULong,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../../kotlin.collections/chunked) Splits this collection into a list of lists each not exceeding the given [size](../../kotlin.collections/chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../../kotlin.collections/chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../../kotlin.collections/chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun ULongArray.component1(): ULong ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun ULongArray.component2(): ULong ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun ULongArray.component3(): ULong ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun ULongArray.component4(): ULong ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun ULongArray.component5(): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../../kotlin.collections/contains) Returns `true` if [element](../../kotlin.collections/contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../../kotlin.collections/contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [contentEquals](../../kotlin.collections/content-equals) Returns `true` if the two specified arrays are *structurally* equal to one another, i.e. contain the same number of the same elements in the same order. ``` infix fun ULongArray.contentEquals(     other: ULongArray ): Boolean ``` ``` infix fun ULongArray?.contentEquals(     other: ULongArray? ): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [contentHashCode](../../kotlin.collections/content-hash-code) Returns a hash code based on the contents of this array as if it is [List](../../kotlin.collections/-list/index#kotlin.collections.List). ``` fun ULongArray.contentHashCode(): Int ``` ``` fun ULongArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [contentToString](../../kotlin.collections/content-to-string) Returns a string representation of the contents of the specified array as if it is [List](../../kotlin.collections/-list/index#kotlin.collections.List). ``` fun ULongArray.contentToString(): String ``` ``` fun ULongArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [copyInto](../../kotlin.collections/copy-into) Copies this array or its subrange into the [destination](../../kotlin.collections/copy-into#kotlin.collections%24copyInto(kotlin.ULongArray,%20kotlin.ULongArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array and returns that array. ``` fun ULongArray.copyInto(     destination: ULongArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [copyOf](../../kotlin.collections/copy-of) Returns new array which is a copy of the original array. ``` fun ULongArray.copyOf(): ULongArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](../../kotlin.collections/copy-of#kotlin.collections%24copyOf(kotlin.ULongArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with zero values if necessary. ``` fun ULongArray.copyOf(newSize: Int): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [copyOfRange](../../kotlin.collections/copy-of-range) Returns a new array which is a copy of the specified range of the original array. ``` fun ULongArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ULongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.count(predicate: (ULong) -> Boolean): Int ``` ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../../kotlin.collections/distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../../kotlin.collections/distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [drop](../../kotlin.collections/drop) Returns a list containing all elements except first [n](../../kotlin.collections/drop#kotlin.collections%24drop(kotlin.ULongArray,%20kotlin.Int)/n) elements. ``` fun ULongArray.drop(n: Int): List<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [dropLast](../../kotlin.collections/drop-last) Returns a list containing all elements except last [n](../../kotlin.collections/drop-last#kotlin.collections%24dropLast(kotlin.ULongArray,%20kotlin.Int)/n) elements. ``` fun ULongArray.dropLast(n: Int): List<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [dropLastWhile](../../kotlin.collections/drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](../../kotlin.collections/drop-last-while#kotlin.collections%24dropLastWhile(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.dropLastWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../../kotlin.collections/drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../../kotlin.collections/drop-while#kotlin.collections%24dropWhile(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.dropWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../../kotlin.collections/element-at-or-else) Returns an element at the given [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.ULongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.ULongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.ULongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/index) is out of bounds of this array. ``` fun ULongArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> ULong ): ULong ``` Returns an element at the given [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.ULongArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.ULongArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun ULongArray.elementAtOrNull(index: Int): ULong? ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [fill](../../kotlin.collections/fill) Fills this array or its subrange with the specified [element](../../kotlin.collections/fill#kotlin.collections%24fill(kotlin.ULongArray,%20kotlin.ULong,%20kotlin.Int,%20kotlin.Int)/element) value. ``` fun ULongArray.fill(     element: ULong,     fromIndex: Int = 0,     toIndex: Int = size) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../../kotlin.collections/filter) Returns a list containing only elements matching the given [predicate](../../kotlin.collections/filter#kotlin.collections%24filter(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.filter(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../../kotlin.collections/filter-indexed) Returns a list containing only elements matching the given [predicate](../../kotlin.collections/filter-indexed#kotlin.collections%24filterIndexed(kotlin.ULongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.filterIndexed(     predicate: (index: Int, ULong) -> Boolean ): List<ULong> ``` ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../../kotlin.collections/filter-indexed-to) Appends all elements matching the given [predicate](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.ULongArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.ULongArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in ULong>> ULongArray.filterIndexedTo(     destination: C,     predicate: (index: Int, ULong) -> Boolean ): C ``` ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../../kotlin.collections/filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../../kotlin.collections/filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../../kotlin.collections/filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../../kotlin.collections/filter-not) Returns a list containing all elements not matching the given [predicate](../../kotlin.collections/filter-not#kotlin.collections%24filterNot(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.filterNot(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../../kotlin.collections/filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../../kotlin.collections/filter-not-null-to) Appends all elements that are not `null` to the given [destination](../../kotlin.collections/filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../../kotlin.collections/filter-not-to) Appends all elements not matching the given [predicate](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.ULongArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.ULongArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in ULong>> ULongArray.filterNotTo(     destination: C,     predicate: (ULong) -> Boolean ): C ``` ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../../kotlin.collections/filter-to) Appends all elements matching the given [predicate](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.ULongArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.ULongArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in ULong>> ULongArray.filterTo(     destination: C,     predicate: (ULong) -> Boolean ): C ``` ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../../kotlin.collections/find) Returns the first element matching the given [predicate](../../kotlin.collections/find#kotlin.collections%24find(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ULongArray.find(predicate: (ULong) -> Boolean): ULong? ``` ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../../kotlin.collections/find-last) Returns the last element matching the given [predicate](../../kotlin.collections/find-last#kotlin.collections%24findLast(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ULongArray.findLast(     predicate: (ULong) -> Boolean ): ULong? ``` ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun ULongArray.first(): ULong ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.first(predicate: (ULong) -> Boolean): ULong ``` ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../../kotlin.collections/first-not-null-of) Returns the first non-null value produced by [transform](../../kotlin.collections/first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../../kotlin.collections/first-not-null-of-or-null) Returns the first non-null value produced by [transform](../../kotlin.collections/first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../../kotlin.collections/first-or-null) Returns the first element, or `null` if the array is empty. ``` fun ULongArray.firstOrNull(): ULong? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun ULongArray.firstOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../../kotlin.collections/flat-map) Returns a single list of all elements yielded from results of [transform](../../kotlin.collections/flat-map#kotlin.collections%24flatMap(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> ULongArray.flatMap(     transform: (ULong) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](../../kotlin.collections/flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../../kotlin.collections/flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../../kotlin.collections/flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.ULongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> ULongArray.flatMapIndexed(     transform: (index: Int, ULong) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](../../kotlin.collections/flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../../kotlin.collections/flat-map-indexed-to) Appends all elements yielded from results of [transform](../../kotlin.collections/flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.ULongArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original array, to the given [destination](../../kotlin.collections/flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.ULongArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> ULongArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, ULong) -> Iterable<R> ): C ``` Appends all elements yielded from results of [transform](../../kotlin.collections/flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../../kotlin.collections/flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../../kotlin.collections/flat-map-to) Appends all elements yielded from results of [transform](../../kotlin.collections/flat-map-to#kotlin.collections%24flatMapTo(kotlin.ULongArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original array, to the given [destination](../../kotlin.collections/flat-map-to#kotlin.collections%24flatMapTo(kotlin.ULongArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> ULongArray.flatMapTo(     destination: C,     transform: (ULong) -> Iterable<R> ): C ``` Appends all elements yielded from results of [transform](../../kotlin.collections/flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../../kotlin.collections/flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../../kotlin.collections/fold) Accumulates value starting with [initial](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.ULongArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.ULong,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.ULongArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.ULong,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> ULongArray.fold(     initial: R,     operation: (acc: R, ULong) -> R ): R ``` ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../../kotlin.collections/fold-indexed) Accumulates value starting with [initial](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.ULongArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.ULong,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.ULongArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.ULong,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> ULongArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): R ``` Accumulates value starting with [initial](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [foldRight](../../kotlin.collections/fold-right) Accumulates value starting with [initial](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.ULongArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.ULong,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.ULongArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.ULong,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> ULongArray.foldRight(     initial: R,     operation: (ULong, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [foldRightIndexed](../../kotlin.collections/fold-right-indexed) Accumulates value starting with [initial](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.ULongArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.ULong,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.ULongArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.ULong,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun <R> ULongArray.foldRightIndexed(     initial: R,     operation: (index: Int, ULong, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../../kotlin.collections/for-each) Performs the given [action](../../kotlin.collections/for-each#kotlin.collections%24forEach(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Unit)))/action) on each element. ``` fun ULongArray.forEach(action: (ULong) -> Unit) ``` ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../../kotlin.collections/for-each-indexed) Performs the given [action](../../kotlin.collections/for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.ULongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun ULongArray.forEachIndexed(     action: (index: Int, ULong) -> Unit) ``` ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getOrElse](../../kotlin.collections/get-or-else) Returns an element at the given [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.ULongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.ULongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.ULongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/index) is out of bounds of this array. ``` fun ULongArray.getOrElse(     index: Int,     defaultValue: (Int) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getOrNull](../../kotlin.collections/get-or-null) Returns an element at the given [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.ULongArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.ULongArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun ULongArray.getOrNull(index: Int): ULong? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../../kotlin.collections/group-by) Groups elements of the original array by the key returned by the given [keySelector](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <K> ULongArray.groupBy(     keySelector: (ULong) -> K ): Map<K, List<ULong>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original array by the key returned by the given [keySelector](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <K, V> ULongArray.groupBy(     keySelector: (ULong) -> K,     valueTransform: (ULong) -> V ): Map<K, List<V>> ``` Groups elements of the original collection by the key returned by the given [keySelector](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../../kotlin.collections/group-by-to) Groups elements of the original array by the key returned by the given [keySelector](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ULongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ULongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<ULong>>> ULongArray.groupByTo(     destination: M,     keySelector: (ULong) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ULongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original array by the key returned by the given [keySelector](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ULongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ULongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> ULongArray.groupByTo(     destination: M,     keySelector: (ULong) -> K,     valueTransform: (ULong) -> V ): M ``` Groups elements of the original collection by the key returned by the given [keySelector](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../../kotlin.collections/grouping-by) Creates a [Grouping](../../kotlin.collections/-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../../kotlin.collections/grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../../kotlin.collections/if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../../kotlin.collections/if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../../kotlin.collections/index-of) Returns first index of [element](../../kotlin.collections/index-of#kotlin.collections%24indexOf(kotlin.ULongArray,%20kotlin.ULong)/element), or -1 if the array does not contain element. ``` fun ULongArray.indexOf(element: ULong): Int ``` Returns first index of [element](../../kotlin.collections/index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../../kotlin.collections/index-of-first) Returns index of the first element matching the given [predicate](../../kotlin.collections/index-of-first#kotlin.collections%24indexOfFirst(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun ULongArray.indexOfFirst(     predicate: (ULong) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](../../kotlin.collections/index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../../kotlin.collections/index-of-last) Returns index of the last element matching the given [predicate](../../kotlin.collections/index-of-last#kotlin.collections%24indexOfLast(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun ULongArray.indexOfLast(     predicate: (ULong) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](../../kotlin.collections/index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../../kotlin.collections/intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../../kotlin.collections/is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../../kotlin.collections/join-to) Appends the string from all the elements separated using [separator](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../../kotlin.collections/join-to-string) Creates a string from all the elements separated using [separator](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../../kotlin.collections/last) Returns the last element. ``` fun ULongArray.last(): ULong ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.last(predicate: (ULong) -> Boolean): ULong ``` ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../../kotlin.collections/last-index-of) Returns last index of [element](../../kotlin.collections/last-index-of#kotlin.collections%24lastIndexOf(kotlin.ULongArray,%20kotlin.ULong)/element), or -1 if the array does not contain element. ``` fun ULongArray.lastIndexOf(element: ULong): Int ``` Returns last index of [element](../../kotlin.collections/last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../../kotlin.collections/last-or-null) Returns the last element, or `null` if the array is empty. ``` fun ULongArray.lastOrNull(): ULong? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ULongArray.lastOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../../kotlin.collections/map) Returns a list containing the results of applying the given [transform](../../kotlin.collections/map#kotlin.collections%24map(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> ULongArray.map(transform: (ULong) -> R): List<R> ``` Returns a list containing the results of applying the given [transform](../../kotlin.collections/map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../../kotlin.collections/map-indexed) Returns a list containing the results of applying the given [transform](../../kotlin.collections/map-indexed#kotlin.collections%24mapIndexed(kotlin.ULongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> ULongArray.mapIndexed(     transform: (index: Int, ULong) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](../../kotlin.collections/map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../../kotlin.collections/map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../../kotlin.collections/map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../../kotlin.collections/map-indexed-not-null-to) Applies the given [transform](../../kotlin.collections/map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../../kotlin.collections/map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../../kotlin.collections/map-indexed-to) Applies the given [transform](../../kotlin.collections/map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.ULongArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original array and appends the results to the given [destination](../../kotlin.collections/map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.ULongArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> ULongArray.mapIndexedTo(     destination: C,     transform: (index: Int, ULong) -> R ): C ``` Applies the given [transform](../../kotlin.collections/map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../../kotlin.collections/map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../../kotlin.collections/map-not-null) Returns a list containing only the non-null results of applying the given [transform](../../kotlin.collections/map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../../kotlin.collections/map-not-null-to) Applies the given [transform](../../kotlin.collections/map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../../kotlin.collections/map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../../kotlin.collections/map-to) Applies the given [transform](../../kotlin.collections/map-to#kotlin.collections%24mapTo(kotlin.ULongArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original array and appends the results to the given [destination](../../kotlin.collections/map-to#kotlin.collections%24mapTo(kotlin.ULongArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> ULongArray.mapTo(     destination: C,     transform: (ULong) -> R ): C ``` Applies the given [transform](../../kotlin.collections/map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../../kotlin.collections/map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../../kotlin.collections/max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <R : Comparable<R>> ULongArray.maxByOrNull(     selector: (ULong) -> R ): ULong? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../../kotlin.collections/max-of) Returns the largest value among all values produced by [selector](../../kotlin.collections/max-of#kotlin.collections%24maxOf(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun ULongArray.maxOf(selector: (ULong) -> Double): Double ``` ``` fun ULongArray.maxOf(selector: (ULong) -> Float): Float ``` ``` fun <R : Comparable<R>> ULongArray.maxOf(     selector: (ULong) -> R ): R ``` Returns the largest value among all values produced by [selector](../../kotlin.collections/max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../../kotlin.collections/max-of-or-null) Returns the largest value among all values produced by [selector](../../kotlin.collections/max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun ULongArray.maxOfOrNull(     selector: (ULong) -> Double ): Double? ``` ``` fun ULongArray.maxOfOrNull(     selector: (ULong) -> Float ): Float? ``` ``` fun <R : Comparable<R>> ULongArray.maxOfOrNull(     selector: (ULong) -> R ): R? ``` Returns the largest value among all values produced by [selector](../../kotlin.collections/max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../../kotlin.collections/max-of-with) Returns the largest value according to the provided [comparator](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.ULongArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.ULongArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> ULongArray.maxOfWith(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R ``` Returns the largest value according to the provided [comparator](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../../kotlin.collections/max-of-with-or-null) Returns the largest value according to the provided [comparator](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.ULongArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.ULongArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> ULongArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R? ``` Returns the largest value according to the provided [comparator](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOrNull](../../kotlin.collections/max-or-null) Returns the largest element or `null` if there are no elements. ``` fun ULongArray.maxOrNull(): ULong? ``` #### [maxWith](../../kotlin.collections/max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../../kotlin.collections/max-with#kotlin.collections%24maxWith(kotlin.ULongArray,%20kotlin.Comparator((kotlin.ULong)))/comparator). ``` fun ULongArray.maxWith(     comparator: Comparator<in ULong> ): ULong ``` ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.3) ``` fun ULongArray.maxWith(     comparator: Comparator<in ULong> ): ULong? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../../kotlin.collections/max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../../kotlin.collections/max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.ULongArray,%20kotlin.Comparator((kotlin.ULong)))/comparator) or `null` if there are no elements. ``` fun ULongArray.maxWithOrNull(     comparator: Comparator<in ULong> ): ULong? ``` ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../../kotlin.collections/min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <R : Comparable<R>> ULongArray.minByOrNull(     selector: (ULong) -> R ): ULong? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../../kotlin.collections/min-of) Returns the smallest value among all values produced by [selector](../../kotlin.collections/min-of#kotlin.collections%24minOf(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun ULongArray.minOf(selector: (ULong) -> Double): Double ``` ``` fun ULongArray.minOf(selector: (ULong) -> Float): Float ``` ``` fun <R : Comparable<R>> ULongArray.minOf(     selector: (ULong) -> R ): R ``` Returns the smallest value among all values produced by [selector](../../kotlin.collections/min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../../kotlin.collections/min-of-or-null) Returns the smallest value among all values produced by [selector](../../kotlin.collections/min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun ULongArray.minOfOrNull(     selector: (ULong) -> Double ): Double? ``` ``` fun ULongArray.minOfOrNull(     selector: (ULong) -> Float ): Float? ``` ``` fun <R : Comparable<R>> ULongArray.minOfOrNull(     selector: (ULong) -> R ): R? ``` Returns the smallest value among all values produced by [selector](../../kotlin.collections/min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../../kotlin.collections/min-of-with) Returns the smallest value according to the provided [comparator](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.ULongArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.ULongArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> ULongArray.minOfWith(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R ``` Returns the smallest value according to the provided [comparator](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../../kotlin.collections/min-of-with-or-null) Returns the smallest value according to the provided [comparator](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.ULongArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.ULongArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.ULong,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> ULongArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R? ``` Returns the smallest value according to the provided [comparator](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOrNull](../../kotlin.collections/min-or-null) Returns the smallest element or `null` if there are no elements. ``` fun ULongArray.minOrNull(): ULong? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../../kotlin.collections/minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../../kotlin.collections/minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../../kotlin.collections/minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../../kotlin.collections/minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../../kotlin.collections/minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../../kotlin.collections/minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../../kotlin.collections/minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../../kotlin.collections/min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../../kotlin.collections/min-with#kotlin.collections%24minWith(kotlin.ULongArray,%20kotlin.Comparator((kotlin.ULong)))/comparator). ``` fun ULongArray.minWith(     comparator: Comparator<in ULong> ): ULong ``` ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.3) ``` fun ULongArray.minWith(     comparator: Comparator<in ULong> ): ULong? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../../kotlin.collections/min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../../kotlin.collections/min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.ULongArray,%20kotlin.Comparator((kotlin.ULong)))/comparator) or `null` if there are no elements. ``` fun ULongArray.minWithOrNull(     comparator: Comparator<in ULong> ): ULong? ``` ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../../kotlin.collections/none) Returns `true` if the array has no elements. ``` fun ULongArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.none(predicate: (ULong) -> Boolean): Boolean ``` ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun ULongArray.onEach(action: (ULong) -> Unit): ULongArray ``` Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../../kotlin.collections/on-each-indexed) Performs the given [action](../../kotlin.collections/on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.ULongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.ULong,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun ULongArray.onEachIndexed(     action: (index: Int, ULong) -> Unit ): ULongArray ``` Performs the given [action](../../kotlin.collections/on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../../kotlin.collections/or-empty) Returns this Collection if it's not `null` and the empty list otherwise. ``` fun <T> Collection<T>?.orEmpty(): Collection<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../../kotlin.collections/plus) Returns an array containing all elements of the original array and then the given [element](../../kotlin.collections/plus#kotlin.collections%24plus(kotlin.ULongArray,%20kotlin.ULong)/element). ``` operator fun ULongArray.plus(element: ULong): ULongArray ``` Returns an array containing all elements of the original array and then all elements of the given [elements](../../kotlin.collections/plus#kotlin.collections%24plus(kotlin.ULongArray,%20kotlin.collections.Collection((kotlin.ULong)))/elements) collection. ``` operator fun ULongArray.plus(     elements: Collection<ULong> ): ULongArray ``` Returns an array containing all elements of the original array and then all elements of the given [elements](../../kotlin.collections/plus#kotlin.collections%24plus(kotlin.ULongArray,%20kotlin.ULongArray)/elements) array. ``` operator fun ULongArray.plus(     elements: ULongArray ): ULongArray ``` Returns a list containing all elements of the original collection and then the given [element](../../kotlin.collections/plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../../kotlin.collections/plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../../kotlin.collections/plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../../kotlin.collections/plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../../kotlin.collections/plus-element) Returns a list containing all elements of the original collection and then the given [element](../../kotlin.collections/plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../../kotlin.collections/random) Returns a random element from this array. ``` fun ULongArray.random(): ULong ``` Returns a random element from this array using the specified source of randomness. ``` fun ULongArray.random(random: Random): ULong ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../../kotlin.collections/random-or-null) Returns a random element from this array, or `null` if this array is empty. ``` fun ULongArray.randomOrNull(): ULong? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun ULongArray.randomOrNull(random: Random): ULong? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../../kotlin.collections/reduce) Accumulates value starting with the first element and applying [operation](../../kotlin.collections/reduce#kotlin.collections%24reduce(kotlin.ULongArray,%20kotlin.Function2((kotlin.ULong,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun ULongArray.reduce(     operation: (acc: ULong, ULong) -> ULong ): ULong ``` ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../../kotlin.collections/reduce-indexed) Accumulates value starting with the first element and applying [operation](../../kotlin.collections/reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.ULongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.ULong,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun ULongArray.reduceIndexed(     operation: (index: Int, acc: ULong, ULong) -> ULong ): ULong ``` Accumulates value starting with the first element and applying [operation](../../kotlin.collections/reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../../kotlin.collections/reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../../kotlin.collections/reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.ULongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.ULong,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun ULongArray.reduceIndexedOrNull(     operation: (index: Int, acc: ULong, ULong) -> ULong ): ULong? ``` Accumulates value starting with the first element and applying [operation](../../kotlin.collections/reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../../kotlin.collections/reduce-or-null) Accumulates value starting with the first element and applying [operation](../../kotlin.collections/reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.ULongArray,%20kotlin.Function2((kotlin.ULong,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun ULongArray.reduceOrNull(     operation: (acc: ULong, ULong) -> ULong ): ULong? ``` ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [reduceRight](../../kotlin.collections/reduce-right) Accumulates value starting with the last element and applying [operation](../../kotlin.collections/reduce-right#kotlin.collections%24reduceRight(kotlin.ULongArray,%20kotlin.Function2((kotlin.ULong,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun ULongArray.reduceRight(     operation: (ULong, acc: ULong) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [reduceRightIndexed](../../kotlin.collections/reduce-right-indexed) Accumulates value starting with the last element and applying [operation](../../kotlin.collections/reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.ULongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.ULong,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun ULongArray.reduceRightIndexed(     operation: (index: Int, ULong, acc: ULong) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](../../kotlin.collections/reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](../../kotlin.collections/reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.ULongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.ULong,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun ULongArray.reduceRightIndexedOrNull(     operation: (index: Int, ULong, acc: ULong) -> ULong ): ULong? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](../../kotlin.collections/reduce-right-or-null) Accumulates value starting with the last element and applying [operation](../../kotlin.collections/reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.ULongArray,%20kotlin.Function2((kotlin.ULong,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun ULongArray.reduceRightOrNull(     operation: (ULong, acc: ULong) -> ULong ): ULong? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun ULongArray.refTo(index: Int): CValuesRef<ULongVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../../kotlin.collections/require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun ULongArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun ULongArray.reverse(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [reversed](../../kotlin.collections/reversed) Returns a list with elements in reversed order. ``` fun ULongArray.reversed(): List<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun ULongArray.reversedArray(): ULongArray ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../../kotlin.collections/running-fold) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/running-fold#kotlin.collections%24runningFold(kotlin.ULongArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.ULong,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/running-fold#kotlin.collections%24runningFold(kotlin.ULongArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.ULong,%20)))/initial) value. ``` fun <R> ULongArray.runningFold(     initial: R,     operation: (acc: R, ULong) -> R ): List<R> ``` ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../../kotlin.collections/running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.ULongArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.ULong,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with [initial](../../kotlin.collections/running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.ULongArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.ULong,%20)))/initial) value. ``` fun <R> ULongArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../../kotlin.collections/running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../../kotlin.collections/running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/running-reduce#kotlin.collections%24runningReduce(kotlin.ULongArray,%20kotlin.Function2((kotlin.ULong,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun ULongArray.runningReduce(     operation: (acc: ULong, ULong) -> ULong ): List<ULong> ``` Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../../kotlin.collections/running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.ULongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.ULong,%20,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with the first element of this array. ``` fun ULongArray.runningReduceIndexed(     operation: (index: Int, acc: ULong, ULong) -> ULong ): List<ULong> ``` Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../../kotlin.collections/scan) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.ULongArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.ULong,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.ULongArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.ULong,%20)))/initial) value. ``` fun <R> ULongArray.scan(     initial: R,     operation: (acc: R, ULong) -> R ): List<R> ``` ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../../kotlin.collections/scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/scan-indexed#kotlin.collections%24scanIndexed(kotlin.ULongArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.ULong,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with [initial](../../kotlin.collections/scan-indexed#kotlin.collections%24scanIndexed(kotlin.ULongArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.ULong,%20)))/initial) value. ``` fun <R> ULongArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../../kotlin.collections/scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [shuffle](../../kotlin.collections/shuffle) Randomly shuffles elements in this array in-place. ``` fun ULongArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.ULongArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun ULongArray.shuffle(random: Random) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../../kotlin.collections/shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../../kotlin.collections/shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../../kotlin.collections/single) Returns the single element, or throws an exception if the array is empty or has more than one element. ``` fun ULongArray.single(): ULong ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun ULongArray.single(predicate: (ULong) -> Boolean): ULong ``` ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../../kotlin.collections/single-or-null) Returns single element, or `null` if the array is empty or has more than one element. ``` fun ULongArray.singleOrNull(): ULong? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun ULongArray.singleOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [slice](../../kotlin.collections/slice) Returns a list containing elements at indices in the specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.ULongArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun ULongArray.slice(indices: IntRange): List<ULong> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.ULongArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun ULongArray.slice(indices: Iterable<Int>): List<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.ULongArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun ULongArray.sliceArray(     indices: Collection<Int> ): ULongArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.ULongArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun ULongArray.sliceArray(indices: IntRange): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sort](../../kotlin.collections/sort) Sorts the array in-place. ``` fun ULongArray.sort() ``` Sorts a range in the array in-place. ``` fun ULongArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun ULongArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun ULongArray.sortDescending(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun ULongArray.sorted(): List<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sortedArray](../../kotlin.collections/sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun ULongArray.sortedArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sortedArrayDescending](../../kotlin.collections/sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun ULongArray.sortedArrayDescending(): ULongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../../kotlin.collections/sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../../kotlin.collections/sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../../kotlin.collections/sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../../kotlin.collections/sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sortedDescending](../../kotlin.collections/sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun ULongArray.sortedDescending(): List<ULong> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../../kotlin.collections/sorted-with) Returns a list of all elements sorted according to the specified [comparator](../../kotlin.collections/sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../../kotlin.collections/subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the array. ``` fun ULongArray.sum(): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../../kotlin.collections/sum-by) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-by#kotlin.collections%24sumBy(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.UInt)))/selector) function applied to each element in the array. ``` fun ULongArray.sumBy(selector: (ULong) -> UInt): UInt ``` Returns the sum of all values produced by [selector](../../kotlin.collections/sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../../kotlin.collections/sum-by-double) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-by-double#kotlin.collections%24sumByDouble(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun ULongArray.sumByDouble(     selector: (ULong) -> Double ): Double ``` Returns the sum of all values produced by [selector](../../kotlin.collections/sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Double)))/selector) function applied to each element in the array. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ULongArray.sumOf(selector: (ULong) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ULongArray.sumOf(selector: (ULong) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ULongArray.sumOf(selector: (ULong) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULongArray.sumOf(selector: (ULong) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULongArray.sumOf(selector: (ULong) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun ULongArray.sumOf(     selector: (ULong) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun ULongArray.sumOf(     selector: (ULong) -> BigInteger ): BigInteger ``` Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [take](../../kotlin.collections/take) Returns a list containing first [n](../../kotlin.collections/take#kotlin.collections%24take(kotlin.ULongArray,%20kotlin.Int)/n) elements. ``` fun ULongArray.take(n: Int): List<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [takeLast](../../kotlin.collections/take-last) Returns a list containing last [n](../../kotlin.collections/take-last#kotlin.collections%24takeLast(kotlin.ULongArray,%20kotlin.Int)/n) elements. ``` fun ULongArray.takeLast(n: Int): List<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [takeLastWhile](../../kotlin.collections/take-last-while) Returns a list containing last elements satisfying the given [predicate](../../kotlin.collections/take-last-while#kotlin.collections%24takeLastWhile(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.takeLastWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../../kotlin.collections/take-while) Returns a list containing first elements satisfying the given [predicate](../../kotlin.collections/take-while#kotlin.collections%24takeWhile(kotlin.ULongArray,%20kotlin.Function1((kotlin.ULong,%20kotlin.Boolean)))/predicate). ``` fun ULongArray.takeWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../../kotlin.collections/to-collection) Appends all elements to the given [destination](../../kotlin.collections/to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun ULongArray.toCValues(): CValues<ULongVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../../kotlin.collections/to-hash-set) Returns a new [HashSet](../../kotlin.collections/-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../../kotlin.collections/to-list) Returns a [List](../../kotlin.collections/-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toLongArray](../../kotlin.collections/to-long-array) Returns an array of type [LongArray](../-long-array/index#kotlin.LongArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun ULongArray.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../../kotlin.collections/to-mutable-set) Returns a new [MutableSet](../../kotlin.collections/-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../../kotlin.collections/to-set) Returns a [Set](../../kotlin.collections/-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toTypedArray](../../kotlin.collections/to-typed-array) Returns a *typed* object array containing all of the elements of this primitive array. ``` fun ULongArray.toTypedArray(): Array<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../../kotlin.collections/to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../../kotlin.collections/union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../../kotlin.collections/windowed) Returns a list of snapshots of the window of the given [size](../../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [withIndex](../../kotlin.collections/with-index) Returns a lazy [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) that wraps each element of the original array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun ULongArray.withIndex(): Iterable<IndexedValue<ULong>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../../kotlin.collections/zip) Returns a list of pairs built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ULongArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> ULongArray.zip(     other: Array<out R> ): List<Pair<ULong, R>> ``` ``` infix fun ULongArray.zip(     other: ULongArray ): List<Pair<ULong, ULong>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ULongArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.ULong,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ULongArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.ULong,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <R, V> ULongArray.zip(     other: Array<out R>,     transform: (a: ULong, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ULongArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> ULongArray.zip(     other: Iterable<R> ): List<Pair<ULong, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ULongArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.ULong,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ULongArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.ULong,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <R, V> ULongArray.zip(     other: Iterable<R>,     transform: (a: ULong, b: R) -> V ): List<V> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ULongArray,%20kotlin.ULongArray,%20kotlin.Function2((kotlin.ULong,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ULongArray,%20kotlin.ULongArray,%20kotlin.Function2((kotlin.ULong,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> ULongArray.zip(     other: ULongArray,     transform: (a: ULong, b: ULong) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../../kotlin.collections/zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../../kotlin.collections/zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun iterator(): Iterator<ULong> ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ULongArray(size: Int) ``` Creates a new array of the specified size, with all elements initialized to zero. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun containsAll(elements: Collection<ULong>): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isEmpty(): Boolean ``` kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun set(index: Int, value: ULong) ``` Sets the element at the given [index](set#kotlin.ULongArray%24set(kotlin.Int,%20kotlin.ULong)/index) to the given [value](set#kotlin.ULongArray%24set(kotlin.Int,%20kotlin.ULong)/value). This method can be called using the index operator. If the [index](set#kotlin.ULongArray%24set(kotlin.Int,%20kotlin.ULong)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) except in Kotlin/JS where the behavior is unspecified. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULongArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun get(index: Int): ULong ``` Returns the array element at the given [index](get#kotlin.ULongArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.ULongArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) except in Kotlin/JS where the behavior is unspecified. kotlin UnsupportedOperationException UnsupportedOperationException ============================= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UnsupportedOperationException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class UnsupportedOperationException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias UnsupportedOperationException = UnsupportedOperationException ``` Constructors ------------ **Platform and version requirements:** JS (1.0), Native (1.0) #### [<init>](-init-) ``` <init>() ``` ``` <init>(message: String?) ``` ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](../../kotlin.native/get-stack-trace-addresses) Returns a list of stack trace addresses representing the stack trace pertaining to this throwable. ``` fun Throwable.getStackTraceAddresses(): List<Long> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UnsupportedOperationException](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` kotlin SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [SIZE\_BITS](-s-i-z-e_-b-i-t-s) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val SIZE_BITS: Int ``` The number of bits used to represent an instance of UInt in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toInt(): Int ``` Converts this [UInt](index) value to [Int](../-int/index#kotlin.Int). If this value is less than or equals to [Int.MAX\_VALUE](../-int/-m-a-x_-v-a-l-u-e#kotlin.Int.Companion%24MAX_VALUE), the resulting `Int` value represents the same numerical value as this `UInt`. Otherwise the result is negative. The resulting `Int` value has the same binary representation as this `UInt` value. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toByte(): Byte ``` Converts this [UInt](index) value to [Byte](../-byte/index#kotlin.Byte). If this value is less than or equals to [Byte.MAX\_VALUE](../-byte/-m-a-x_-v-a-l-u-e#kotlin.Byte.Companion%24MAX_VALUE), the resulting `Byte` value represents the same numerical value as this `UInt`. The resulting `Byte` value is represented by the least significant 8 bits of this `UInt` value. Note that the resulting `Byte` value may be negative. kotlin shr shr === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <shr> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun shr(bitCount: Int): UInt ``` Shifts this value right by the [bitCount](shr#kotlin.UInt%24shr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with zeros. Note that only the five lowest-order bits of the [bitCount](shr#kotlin.UInt%24shr(kotlin.Int)/bitCount) are used as the shift distance. The shift distance actually used is therefore always in the range `0..31`. kotlin UInt UInt ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline class UInt : Comparable<UInt> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <and> Performs a bitwise AND operation between the two values. ``` infix fun and(other: UInt): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareTo](compare-to) Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other. ``` operator fun compareTo(other: UByte): Int ``` ``` operator fun compareTo(other: UShort): Int ``` ``` operator fun compareTo(other: UInt): Int ``` ``` operator fun compareTo(other: ULong): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <dec> Returns this value decremented by one. ``` operator fun dec(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <div> Divides this value by the other value, truncating the result to an integer that is closer to zero. ``` operator fun div(other: UByte): UInt ``` ``` operator fun div(other: UShort): UInt ``` ``` operator fun div(other: UInt): UInt ``` ``` operator fun div(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [floorDiv](floor-div) Divides this value by the other value, flooring the result to an integer that is closer to negative infinity. ``` fun floorDiv(other: UByte): UInt ``` ``` fun floorDiv(other: UShort): UInt ``` ``` fun floorDiv(other: UInt): UInt ``` ``` fun floorDiv(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inc> Returns this value incremented by one. ``` operator fun inc(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inv> Inverts the bits in this value. ``` fun inv(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <minus> Subtracts the other value from this value. ``` operator fun minus(other: UByte): UInt ``` ``` operator fun minus(other: UShort): UInt ``` ``` operator fun minus(other: UInt): UInt ``` ``` operator fun minus(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <mod> Calculates the remainder of flooring division of this value by the other value. ``` fun mod(other: UByte): UByte ``` ``` fun mod(other: UShort): UShort ``` ``` fun mod(other: UInt): UInt ``` ``` fun mod(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <or> Performs a bitwise OR operation between the two values. ``` infix fun or(other: UInt): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Adds the other value to this value. ``` operator fun plus(other: UByte): UInt ``` ``` operator fun plus(other: UShort): UInt ``` ``` operator fun plus(other: UInt): UInt ``` ``` operator fun plus(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](range-to) Creates a range from this value to the specified [other](range-to#kotlin.UInt%24rangeTo(kotlin.UInt)/other) value. ``` operator fun rangeTo(other: UInt): UIntRange ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [rangeUntil](range-until) Creates a range from this value up to but excluding the specified [other](range-until#kotlin.UInt%24rangeUntil(kotlin.UInt)/other) value. ``` operator fun rangeUntil(other: UInt): UIntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <rem> Calculates the remainder of truncating division of this value by the other value. ``` operator fun rem(other: UByte): UInt ``` ``` operator fun rem(other: UShort): UInt ``` ``` operator fun rem(other: UInt): UInt ``` ``` operator fun rem(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <shl> Shifts this value left by the [bitCount](shl#kotlin.UInt%24shl(kotlin.Int)/bitCount) number of bits. ``` infix fun shl(bitCount: Int): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <shr> Shifts this value right by the [bitCount](shr#kotlin.UInt%24shr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with zeros. ``` infix fun shr(bitCount: Int): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <times> Multiplies this value by the other value. ``` operator fun times(other: UByte): UInt ``` ``` operator fun times(other: UShort): UInt ``` ``` operator fun times(other: UInt): UInt ``` ``` operator fun times(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Converts this [UInt](index) value to [Byte](../-byte/index#kotlin.Byte). ``` fun toByte(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDouble](to-double) Converts this [UInt](index) value to [Double](../-double/index#kotlin.Double). ``` fun toDouble(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloat](to-float) Converts this [UInt](index) value to [Float](../-float/index#kotlin.Float). ``` fun toFloat(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toInt](to-int) Converts this [UInt](index) value to [Int](../-int/index#kotlin.Int). ``` fun toInt(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLong](to-long) Converts this [UInt](index) value to [Long](../-long/index#kotlin.Long). ``` fun toLong(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShort](to-short) Converts this [UInt](index) value to [Short](../-short/index#kotlin.Short). ``` fun toShort(): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns a string representation of the object. ``` fun toString(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toUByte](to-u-byte) Converts this [UInt](index) value to [UByte](../-u-byte/index). ``` fun toUByte(): UByte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toUInt](to-u-int) Returns this value. ``` fun toUInt(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toULong](to-u-long) Converts this [UInt](index) value to [ULong](../-u-long/index). ``` fun toULong(): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toUShort](to-u-short) Converts this [UInt](index) value to [UShort](../-u-short/index). ``` fun toUShort(): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <xor> Performs a bitwise XOR operation between the two values. ``` infix fun xor(other: UInt): UInt ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MAX\_VALUE](-m-a-x_-v-a-l-u-e) A constant holding the maximum value an instance of UInt can have. ``` const val MAX_VALUE: UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MIN\_VALUE](-m-i-n_-v-a-l-u-e) A constant holding the minimum value an instance of UInt can have. ``` const val MIN_VALUE: UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SIZE\_BITS](-s-i-z-e_-b-i-t-s) The number of bits used to represent an instance of UInt in a binary form. ``` const val SIZE_BITS: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) The number of bytes used to represent an instance of UInt in a binary form. ``` const val SIZE_BYTES: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceAtLeast](../../kotlin.ranges/coerce-at-least) Ensures that this value is not less than the specified [minimumValue](../../kotlin.ranges/coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.UInt,%20kotlin.UInt)/minimumValue). ``` fun UInt.coerceAtLeast(minimumValue: UInt): UInt ``` ``` fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceAtMost](../../kotlin.ranges/coerce-at-most) Ensures that this value is not greater than the specified [maximumValue](../../kotlin.ranges/coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.UInt,%20kotlin.UInt)/maximumValue). ``` fun UInt.coerceAtMost(maximumValue: UInt): UInt ``` ``` fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceIn](../../kotlin.ranges/coerce-in) Ensures that this value lies in the specified range [minimumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.UInt,%20kotlin.UInt)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.UInt,%20kotlin.UInt)/maximumValue). ``` fun UInt.coerceIn(     minimumValue: UInt,     maximumValue: UInt ): UInt ``` ``` fun <T : Comparable<T>> T.coerceIn(     minimumValue: T?,     maximumValue: T? ): T ``` Ensures that this value lies in the specified [range](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.ranges.ClosedRange((kotlin.UInt)))/range). ``` fun UInt.coerceIn(range: ClosedRange<UInt>): UInt ``` ``` fun <T : Comparable<T>> T.coerceIn(     range: ClosedFloatingPointRange<T> ): T ``` ``` fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [compareTo](../compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other) object, a negative number if it's less than [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other), or a positive number if it's greater than [other](../compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other). ``` infix fun <T> Comparable<T>.compareTo(other: T): Int ``` **Platform and version requirements:** Native (1.3) #### [convert](../../kotlinx.cinterop/convert) ``` fun <R : Any> UInt.convert(): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [countLeadingZeroBits](../count-leading-zero-bits) Counts the number of consecutive most significant bits that are zero in the binary representation of this [UInt](index) number. ``` fun UInt.countLeadingZeroBits(): Int ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [countOneBits](../count-one-bits) Counts the number of set bits in the binary representation of this [UInt](index) number. ``` fun UInt.countOneBits(): Int ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [countTrailingZeroBits](../count-trailing-zero-bits) Counts the number of consecutive least significant bits that are zero in the binary representation of this [UInt](index) number. ``` fun UInt.countTrailingZeroBits(): Int ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [downTo](../../kotlin.ranges/down-to) Returns a progression from this value down to the specified [to](../../kotlin.ranges/down-to#kotlin.ranges%24downTo(kotlin.UInt,%20kotlin.UInt)/to) value with the step -1. ``` infix fun UInt.downTo(to: UInt): UIntProgression ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](../../kotlin.ranges/range-to) Creates a range from this [Comparable](../-comparable/index#kotlin.Comparable) value to the specified [that](../../kotlin.ranges/range-to#kotlin.ranges%24rangeTo(kotlin.ranges.rangeTo.T,%20kotlin.ranges.rangeTo.T)/that) value. ``` operator fun <T : Comparable<T>> T.rangeTo(     that: T ): ClosedRange<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [rangeUntil](../../kotlin.ranges/range-until) Creates an open-ended range from this [Comparable](../-comparable/index#kotlin.Comparable) value to the specified [that](../../kotlin.ranges/range-until#kotlin.ranges%24rangeUntil(kotlin.ranges.rangeUntil.T,%20kotlin.ranges.rangeUntil.T)/that) value. ``` operator fun <T : Comparable<T>> T.rangeUntil(     that: T ): OpenEndRange<T> ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateLeft](../rotate-left) Rotates the binary representation of this [UInt](index) number left by the specified [bitCount](../rotate-left#kotlin%24rotateLeft(kotlin.UInt,%20kotlin.Int)/bitCount) number of bits. The most significant bits pushed out from the left side reenter the number as the least significant bits on the right side. ``` fun UInt.rotateLeft(bitCount: Int): UInt ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateRight](../rotate-right) Rotates the binary representation of this [UInt](index) number right by the specified [bitCount](../rotate-right#kotlin%24rotateRight(kotlin.UInt,%20kotlin.Int)/bitCount) number of bits. The least significant bits pushed out from the right side reenter the number as the most significant bits on the left side. ``` fun UInt.rotateRight(bitCount: Int): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [takeHighestOneBit](../take-highest-one-bit) Returns a number having a single bit set in the position of the most significant set bit of this [UInt](index) number, or zero, if this number is zero. ``` fun UInt.takeHighestOneBit(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [takeLowestOneBit](../take-lowest-one-bit) Returns a number having a single bit set in the position of the least significant set bit of this [UInt](index) number, or zero, if this number is zero. ``` fun UInt.takeLowestOneBit(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toString](../../kotlin.text/to-string) Returns a string representation of this [Int](../-int/index#kotlin.Int) value in the specified [radix](../../kotlin.text/to-string#kotlin.text%24toString(kotlin.UInt,%20kotlin.Int)/radix). ``` fun UInt.toString(radix: Int): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [until](../../kotlin.ranges/until) Returns a range from this value up to but excluding the specified [to](../../kotlin.ranges/until#kotlin.ranges%24until(kotlin.UInt,%20kotlin.UInt)/to) value. ``` infix fun UInt.until(to: UInt): UIntRange ```
programming_docs
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val SIZE_BYTES: Int ``` The number of bytes used to represent an instance of UInt in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [MIN\_VALUE](-m-i-n_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val MIN_VALUE: UInt ``` A constant holding the minimum value an instance of UInt can have. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toLong(): Long ``` Converts this [UInt](index) value to [Long](../-long/index#kotlin.Long). The resulting `Long` value represents the same numerical value as this `UInt`. The least significant 32 bits of the resulting `Long` value are the same as the bits of this `UInt` value, whereas the most significant 32 bits are filled with zeros. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [MAX\_VALUE](-m-a-x_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val MAX_VALUE: UInt ``` A constant holding the maximum value an instance of UInt can have. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun compareTo(other: UByte): Int ``` ``` operator fun compareTo(other: UShort): Int ``` ``` operator fun compareTo(other: UInt): Int ``` ``` operator fun compareTo(other: ULong): Int ``` Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other. kotlin rangeTo rangeTo ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [rangeTo](range-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rangeTo(other: UInt): UIntRange ``` Creates a range from this value to the specified [other](range-to#kotlin.UInt%24rangeTo(kotlin.UInt)/other) value. kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <rem> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rem(other: UByte): UInt ``` ``` operator fun rem(other: UShort): UInt ``` ``` operator fun rem(other: UInt): UInt ``` ``` operator fun rem(other: ULong): ULong ``` Calculates the remainder of truncating division of this value by the other value. The result is always less than the divisor. kotlin shl shl === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <shl> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun shl(bitCount: Int): UInt ``` Shifts this value left by the [bitCount](shl#kotlin.UInt%24shl(kotlin.Int)/bitCount) number of bits. Note that only the five lowest-order bits of the [bitCount](shl#kotlin.UInt%24shl(kotlin.Int)/bitCount) are used as the shift distance. The shift distance actually used is therefore always in the range `0..31`. kotlin rangeUntil rangeUntil ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [rangeUntil](range-until) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: UInt ): UIntRange ``` Creates a range from this value up to but excluding the specified [other](range-until#kotlin.UInt%24rangeUntil(kotlin.UInt)/other) value. If the [other](range-until#kotlin.UInt%24rangeUntil(kotlin.UInt)/other) value is less than or equal to `this` value, then the returned range is empty. kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <div> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: UByte): UInt ``` ``` operator fun div(other: UShort): UInt ``` ``` operator fun div(other: UInt): UInt ``` ``` operator fun div(other: ULong): ULong ``` Divides this value by the other value, truncating the result to an integer that is closer to zero. kotlin toDouble toDouble ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toDouble(): Double ``` Converts this [UInt](index) value to [Double](../-double/index#kotlin.Double). The resulting `Double` value represents the same numerical value as this `UInt`. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun dec(): UInt ``` Returns this value decremented by one. ``` fun main(args: Array<String>) { //sampleStart val a = 3 val b = a.dec() println(a) // 3 println(b) // 2 var x = 3 val y = x-- println(x) // 2 println(y) // 3 val z = --x println(x) // 1 println(z) // 1 //sampleEnd } ``` kotlin and and === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <and> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun and(other: UInt): UInt ``` Performs a bitwise AND operation between the two values. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun inc(): UInt ``` Returns this value incremented by one. ``` fun main(args: Array<String>) { //sampleStart val a = 3 val b = a.inc() println(a) // 3 println(b) // 4 var x = 3 val y = x++ println(x) // 4 println(y) // 3 val z = ++x println(x) // 5 println(z) // 5 //sampleEnd } ``` kotlin inv inv === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <inv> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun inv(): UInt ``` Inverts the bits in this value. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toString(): String ``` Returns a string representation of the object. kotlin toUInt toUInt ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toUInt](to-u-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUInt(): UInt ``` Returns this value. kotlin xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <xor> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun xor(other: UInt): UInt ``` Performs a bitwise XOR operation between the two values. kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <times> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun times(other: UByte): UInt ``` ``` operator fun times(other: UShort): UInt ``` ``` operator fun times(other: UInt): UInt ``` ``` operator fun times(other: ULong): ULong ``` Multiplies this value by the other value. kotlin mod mod === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <mod> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun mod(other: UByte): UByte ``` ``` fun mod(other: UShort): UShort ``` ``` fun mod(other: UInt): UInt ``` ``` fun mod(other: ULong): ULong ``` Calculates the remainder of flooring division of this value by the other value. The result is always less than the divisor. For unsigned types, the remainders of flooring division and truncating division are the same. kotlin toFloat toFloat ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toFloat(): Float ``` Converts this [UInt](index) value to [Float](../-float/index#kotlin.Float). The resulting value is the closest `Float` to this `UInt` value. In case when this `UInt` value is exactly between two `Float`s, the one with zero at least significant bit of mantissa is selected. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: UByte): UInt ``` ``` operator fun minus(other: UShort): UInt ``` ``` operator fun minus(other: UInt): UInt ``` ``` operator fun minus(other: ULong): ULong ``` Subtracts the other value from this value. kotlin toUByte toUByte ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toUByte](to-u-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUByte(): UByte ``` Converts this [UInt](index) value to [UByte](../-u-byte/index). If this value is less than or equals to [UByte.MAX\_VALUE](../-u-byte/-m-a-x_-v-a-l-u-e), the resulting `UByte` value represents the same numerical value as this `UInt`. The resulting `UByte` value is represented by the least significant 8 bits of this `UInt` value. kotlin floorDiv floorDiv ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [floorDiv](floor-div) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun floorDiv(other: UByte): UInt ``` ``` fun floorDiv(other: UShort): UInt ``` ``` fun floorDiv(other: UInt): UInt ``` ``` fun floorDiv(other: ULong): ULong ``` Divides this value by the other value, flooring the result to an integer that is closer to negative infinity. For unsigned types, the results of flooring division and truncating division are the same. kotlin toShort toShort ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toShort(): Short ``` Converts this [UInt](index) value to [Short](../-short/index#kotlin.Short). If this value is less than or equals to [Short.MAX\_VALUE](../-short/-m-a-x_-v-a-l-u-e#kotlin.Short.Companion%24MAX_VALUE), the resulting `Short` value represents the same numerical value as this `UInt`. The resulting `Short` value is represented by the least significant 16 bits of this `UInt` value. Note that the resulting `Short` value may be negative. kotlin toULong toULong ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toULong](to-u-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toULong(): ULong ``` Converts this [UInt](index) value to [ULong](../-u-long/index). The resulting `ULong` value represents the same numerical value as this `UInt`. The least significant 32 bits of the resulting `ULong` value are the same as the bits of this `UInt` value, whereas the most significant 32 bits are filled with zeros. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun plus(other: UByte): UInt ``` ``` operator fun plus(other: UShort): UInt ``` ``` operator fun plus(other: UInt): UInt ``` ``` operator fun plus(other: ULong): ULong ``` Adds the other value to this value. kotlin or or == [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / <or> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun or(other: UInt): UInt ``` Performs a bitwise OR operation between the two values. kotlin toUShort toUShort ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UInt](index) / [toUShort](to-u-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUShort(): UShort ``` Converts this [UInt](index) value to [UShort](../-u-short/index). If this value is less than or equals to [UShort.MAX\_VALUE](../-u-short/-m-a-x_-v-a-l-u-e), the resulting `UShort` value represents the same numerical value as this `UInt`. The resulting `UShort` value is represented by the least significant 16 bits of this `UInt` value. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` abstract fun toInt(): Int ``` Returns the value of this number as an [Int](../-int/index#kotlin.Int), which may involve rounding or truncation. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` abstract fun toByte(): Byte ``` Returns the value of this number as a [Byte](../-byte/index#kotlin.Byte), which may involve rounding or truncation. kotlin Number Number ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` abstract class Number ``` Superclass for all platform classes representing numeric values. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Superclass for all platform classes representing numeric values. ``` <init>() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Returns the value of this number as a [Byte](../-byte/index#kotlin.Byte), which may involve rounding or truncation. ``` abstract fun toByte(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toChar](to-char) Returns the [Char](../-char/index#kotlin.Char) with the numeric value equal to this number, truncated to 16 bits if appropriate. ``` abstract fun toChar(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDouble](to-double) Returns the value of this number as a [Double](../-double/index#kotlin.Double), which may involve rounding. ``` abstract fun toDouble(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloat](to-float) Returns the value of this number as a [Float](../-float/index#kotlin.Float), which may involve rounding. ``` abstract fun toFloat(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toInt](to-int) Returns the value of this number as an [Int](../-int/index#kotlin.Int), which may involve rounding or truncation. ``` abstract fun toInt(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLong](to-long) Returns the value of this number as a [Long](../-long/index#kotlin.Long), which may involve rounding or truncation. ``` abstract fun toLong(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShort](to-short) Returns the value of this number as a [Short](../-short/index#kotlin.Short), which may involve rounding or truncation. ``` abstract fun toShort(): Short ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [narrow](../../kotlinx.cinterop/narrow) ``` fun <R : Number> Number.narrow(): R ``` **Platform and version requirements:** Native (1.3) #### [signExtend](../../kotlinx.cinterop/sign-extend) ``` fun <R : Number> Number.signExtend(): R ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Byte](../-byte/index) Represents a 8-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type `byte`. ``` class Byte : Number, Comparable<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Double](../-double/index) Represents a double-precision 64-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type `double`. ``` class Double : Number, Comparable<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Float](../-float/index) Represents a single-precision 32-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type `float`. ``` class Float : Number, Comparable<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Int](../-int/index) Represents a 32-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type `int`. ``` class Int : Number, Comparable<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Long](../-long/index) Represents a 64-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type `long`. ``` class Long : Number, Comparable<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Short](../-short/index) Represents a 16-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type `short`. ``` class Short : Number, Comparable<Short> ``` kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` abstract fun toLong(): Long ``` Returns the value of this number as a [Long](../-long/index#kotlin.Long), which may involve rounding or truncation. kotlin toDouble toDouble ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` abstract fun toDouble(): Double ``` Returns the value of this number as a [Double](../-double/index#kotlin.Double), which may involve rounding. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>() ``` Superclass for all platform classes representing numeric values. kotlin toFloat toFloat ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` abstract fun toFloat(): Float ``` Returns the value of this number as a [Float](../-float/index#kotlin.Float), which may involve rounding.
programming_docs
kotlin toShort toShort ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` abstract fun toShort(): Short ``` Returns the value of this number as a [Short](../-short/index#kotlin.Short), which may involve rounding or truncation. kotlin toChar toChar ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Number](index) / [toChar](to-char) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` abstract fun toChar(): Char ``` Returns the [Char](../-char/index#kotlin.Char) with the numeric value equal to this number, truncated to 16 bits if appropriate. kotlin Package kotlin.streams Package kotlin.streams ====================== [kotlin-stdlib](../../../../../index) / [kotlin.streams](index) Utility functions for working with Java 8 [streams](https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html). Extensions for External Classes ------------------------------- **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [java.util.stream.DoubleStream](java.util.stream.-double-stream/index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [java.util.stream.IntStream](java.util.stream.-int-stream/index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [java.util.stream.LongStream](java.util.stream.-long-stream/index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [java.util.stream.Stream](java.util.stream.-stream/index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [kotlin.sequences.Sequence](kotlin.sequences.-sequence/index) kotlin toList toList ====== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.DoubleStream](index) / [toList](to-list) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun DoubleStream.toList(): List<Double> ``` Returns a List containing all elements produced by this stream. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val doubleStream: DoubleStream = DoubleStream.of(1e2, 1e3, 1e4) val doubleList: List<Double> = doubleStream.toList() println(doubleList) // [100.0, 1000.0, 10000.0] //sampleEnd } ``` kotlin Extensions for java.util.stream.DoubleStream Extensions for java.util.stream.DoubleStream ============================================ [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.DoubleStream](index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [asSequence](as-sequence) Creates a Sequence instance that wraps the original stream iterating through its elements. ``` fun DoubleStream.asSequence(): Sequence<Double> ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [toList](to-list) Returns a List containing all elements produced by this stream. ``` fun DoubleStream.toList(): List<Double> ``` kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.DoubleStream](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun DoubleStream.asSequence(): Sequence<Double> ``` Creates a Sequence instance that wraps the original stream iterating through its elements. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val doubleStream: DoubleStream = DoubleStream.of(1e2, 1e3, 1e4) val doubleSequence: Sequence<Double> = doubleStream.asSequence() println(doubleSequence.joinToString(", ")) // 100.0, 1000.0, 10000.0 //sampleEnd } ``` kotlin Extensions for kotlin.sequences.Sequence Extensions for kotlin.sequences.Sequence ======================================== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [kotlin.sequences.Sequence](index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [asStream](as-stream) Creates a sequential [Stream](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html) instance that produces elements from the original sequence. ``` fun <T> Sequence<T>.asStream(): Stream<T> ``` kotlin asStream asStream ======== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [kotlin.sequences.Sequence](index) / [asStream](as-stream) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun <T> Sequence<T>.asStream(): Stream<T> ``` Creates a sequential [Stream](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html) instance that produces elements from the original sequence. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val evenNumbersSequence: Sequence<Int> = generateSequence(2, { it + 2 }).take(5) val evenNumberStream: Stream<Int> = evenNumbersSequence.asStream() println(evenNumberStream.toList()) // [2, 4, 6, 8, 10] //sampleEnd } ``` kotlin toList toList ====== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.IntStream](index) / [toList](to-list) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun IntStream.toList(): List<Int> ``` Returns a List containing all elements produced by this stream. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val intStream: IntStream = IntStream.of(10, 20, 30) val intList: List<Int> = intStream.toList() println(intList) // [10, 20, 30] //sampleEnd } ``` kotlin Extensions for java.util.stream.IntStream Extensions for java.util.stream.IntStream ========================================= [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.IntStream](index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [asSequence](as-sequence) Creates a Sequence instance that wraps the original stream iterating through its elements. ``` fun IntStream.asSequence(): Sequence<Int> ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [toList](to-list) Returns a List containing all elements produced by this stream. ``` fun IntStream.toList(): List<Int> ``` kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.IntStream](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun IntStream.asSequence(): Sequence<Int> ``` Creates a Sequence instance that wraps the original stream iterating through its elements. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val intStream: IntStream = IntStream.of(5, 6, 7) val intSequence: Sequence<Int> = intStream.asSequence() println(intSequence.joinToString(", ")) // 5, 6, 7 //sampleEnd } ``` kotlin toList toList ====== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.LongStream](index) / [toList](to-list) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun LongStream.toList(): List<Long> ``` Returns a List containing all elements produced by this stream. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val longStream: LongStream = LongStream.of(3_000_000_000, 4_000_000_000, 5_000_000_000) val longList: List<Long> = longStream.toList() println(longList) // [3000000000, 4000000000, 5000000000] //sampleEnd } ``` kotlin Extensions for java.util.stream.LongStream Extensions for java.util.stream.LongStream ========================================== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.LongStream](index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [asSequence](as-sequence) Creates a Sequence instance that wraps the original stream iterating through its elements. ``` fun LongStream.asSequence(): Sequence<Long> ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [toList](to-list) Returns a List containing all elements produced by this stream. ``` fun LongStream.toList(): List<Long> ``` kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.LongStream](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun LongStream.asSequence(): Sequence<Long> ``` Creates a Sequence instance that wraps the original stream iterating through its elements. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val longStream: LongStream = LongStream.of(5_000_000_000, 6_000_000_000, 7_000_000_000) val longSequence: Sequence<Long> = longStream.asSequence() println(longSequence.joinToString(", ")) // 5000000000, 6000000000, 7000000000 //sampleEnd } ``` kotlin toList toList ====== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.Stream](index) / [toList](to-list) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun <T> Stream<T>.toList(): List<T> ``` Returns a List containing all elements produced by this stream. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val stringStream: Stream<String> = Stream.of("Lion", "Leopard", "Jaguar", "Tiger") val stringList: List<String> = stringStream.toList() println(stringList) // [Lion, Leopard, Jaguar, Tiger] //sampleEnd } ``` kotlin Extensions for java.util.stream.Stream Extensions for java.util.stream.Stream ====================================== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.Stream](index) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [asSequence](as-sequence) Creates a Sequence instance that wraps the original stream iterating through its elements. ``` fun <T> Stream<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [toList](to-list) Returns a List containing all elements produced by this stream. ``` fun <T> Stream<T>.toList(): List<T> ``` kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../../index) / [kotlin.streams](../index) / [java.util.stream.Stream](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun <T> Stream<T>.asSequence(): Sequence<T> ``` Creates a Sequence instance that wraps the original stream iterating through its elements. ``` import java.util.stream.* import kotlin.streams.* fun main(args: Array<String>) { //sampleStart val stringStream: Stream<String> = Stream.of("Never", "gonna", "give", "you", "up") val stringSequence: Sequence<String> = stringStream.asSequence() println(stringSequence.joinToString(" ")) // Never gonna give you up //sampleEnd } ``` kotlin Package kotlin.coroutines.cancellation Package kotlin.coroutines.cancellation ====================================== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines.cancellation](index) Exceptions ---------- #### [CancellationException](-cancellation-exception/index) Thrown by cancellable suspending functions if the coroutine is cancelled while it is suspended. It indicates *normal* cancellation of a coroutine. **Platform and version requirements:** JS (1.4), Native (1.4) ``` open class CancellationException : IllegalStateException ``` **Platform and version requirements:** JVM (1.4) ``` typealias CancellationException = CancellationException ``` Functions --------- **Platform and version requirements:** JVM (1.4) #### [CancellationException](-cancellation-exception) Creates an instance of [CancellationException](-cancellation-exception/index#kotlin.coroutines.cancellation.CancellationException) with the given [message](-cancellation-exception#kotlin.coroutines.cancellation%24CancellationException(kotlin.String?,%20kotlin.Throwable?)/message) and [cause](-cancellation-exception#kotlin.coroutines.cancellation%24CancellationException(kotlin.String?,%20kotlin.Throwable?)/cause). ``` fun CancellationException(     message: String?,     cause: Throwable? ): CancellationException ``` Creates an instance of [CancellationException](-cancellation-exception/index#kotlin.coroutines.cancellation.CancellationException) with the given [cause](-cancellation-exception#kotlin.coroutines.cancellation%24CancellationException(kotlin.Throwable?)/cause). ``` fun CancellationException(     cause: Throwable? ): CancellationException ``` kotlin CancellationException CancellationException ===================== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines.cancellation](index) / [CancellationException](-cancellation-exception) **Platform and version requirements:** JVM (1.4) ``` fun CancellationException(     message: String?,     cause: Throwable? ): CancellationException ``` Creates an instance of [CancellationException](-cancellation-exception/index#kotlin.coroutines.cancellation.CancellationException) with the given [message](-cancellation-exception#kotlin.coroutines.cancellation%24CancellationException(kotlin.String?,%20kotlin.Throwable?)/message) and [cause](-cancellation-exception#kotlin.coroutines.cancellation%24CancellationException(kotlin.String?,%20kotlin.Throwable?)/cause). **Platform and version requirements:** JVM (1.4) ``` fun CancellationException(     cause: Throwable? ): CancellationException ``` Creates an instance of [CancellationException](-cancellation-exception/index#kotlin.coroutines.cancellation.CancellationException) with the given [cause](-cancellation-exception#kotlin.coroutines.cancellation%24CancellationException(kotlin.Throwable?)/cause). kotlin CancellationException CancellationException ===================== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines.cancellation](../index) / [CancellationException](index) **Platform and version requirements:** JS (1.4), Native (1.4) ``` open class CancellationException : IllegalStateException ``` **Platform and version requirements:** JVM (1.4) ``` typealias CancellationException = CancellationException ``` Thrown by cancellable suspending functions if the coroutine is cancelled while it is suspended. It indicates *normal* cancellation of a coroutine. Constructors ------------ #### [<init>](-init-) **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>() ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>(message: String?) ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>(message: String?, cause: Throwable?) ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>(cause: Throwable?) ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](../../kotlin.native/get-stack-trace-addresses) Returns a list of stack trace addresses representing the stack trace pertaining to this throwable. ``` fun Throwable.getStackTraceAddresses(): List<Long> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines.cancellation](../index) / [CancellationException](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` **Platform and version requirements:** JS (1.1), Native (1.1) ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` kotlin Package kotlinx.cinterop.internal Package kotlinx.cinterop.internal ================================= [kotlin-stdlib](../../../../../index) / [kotlinx.cinterop.internal](index) Types ----- **Platform and version requirements:** Native (1.3) #### [ConstantValue](-constant-value/index) Collection of annotations that allow to store constant values. ``` object ConstantValue ``` Annotations ----------- **Platform and version requirements:** Native (1.3) #### [CCall](-c-call/index) ``` annotation class CCall ``` **Platform and version requirements:** Native (1.3) #### [CEnumEntryAlias](-c-enum-entry-alias/index) Denotes property that is an alias to some enum entry. ``` annotation class CEnumEntryAlias ``` **Platform and version requirements:** Native (1.3) #### [CEnumVarTypeSize](-c-enum-var-type-size/index) Stores instance size of the type T: CEnumVar. ``` annotation class CEnumVarTypeSize ``` **Platform and version requirements:** Native (1.3) #### [CStruct](-c-struct/index) ``` annotation class CStruct ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CEnumVarTypeSize](index) / <size> **Platform and version requirements:** Native (1.3) ``` val size: Int ``` kotlin CEnumVarTypeSize CEnumVarTypeSize ================ [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CEnumVarTypeSize](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.CLASS]) annotation class CEnumVarTypeSize ``` Stores instance size of the type T: CEnumVar. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) Stores instance size of the type T: CEnumVar. ``` CEnumVarTypeSize(size: Int) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <size> ``` val size: Int ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CEnumVarTypeSize](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` CEnumVarTypeSize(size: Int) ``` Stores instance size of the type T: CEnumVar. kotlin CEnumEntryAlias CEnumEntryAlias =============== [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CEnumEntryAlias](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.CLASS]) annotation class CEnumEntryAlias ``` Denotes property that is an alias to some enum entry. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) Denotes property that is an alias to some enum entry. ``` CEnumEntryAlias(entryName: String) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### [entryName](entry-name) ``` val entryName: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CEnumEntryAlias](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` CEnumEntryAlias(entryName: String) ``` Denotes property that is an alias to some enum entry. kotlin entryName entryName ========= [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CEnumEntryAlias](index) / [entryName](entry-name) **Platform and version requirements:** Native (1.3) ``` val entryName: String ``` kotlin ConstantValue ConstantValue ============= [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [ConstantValue](index) **Platform and version requirements:** Native (1.3) ``` object ConstantValue ``` Collection of annotations that allow to store constant values. Annotations ----------- **Platform and version requirements:** Native (1.3) #### [Byte](-byte/index) ``` annotation class Byte ``` **Platform and version requirements:** Native (1.3) #### [Double](-double/index) ``` annotation class Double ``` **Platform and version requirements:** Native (1.3) #### [Float](-float/index) ``` annotation class Float ``` **Platform and version requirements:** Native (1.3) #### [Int](-int/index) ``` annotation class Int ``` **Platform and version requirements:** Native (1.3) #### [Long](-long/index) ``` annotation class Long ``` **Platform and version requirements:** Native (1.3) #### [Short](-short/index) ``` annotation class Short ``` **Platform and version requirements:** Native (1.3) #### [String](-string/index) ``` annotation class String ``` **Platform and version requirements:** Native (1.3) #### [UByte](-u-byte/index) ``` annotation class UByte ``` **Platform and version requirements:** Native (1.3) #### [UInt](-u-int/index) ``` annotation class UInt ``` **Platform and version requirements:** Native (1.3) #### [ULong](-u-long/index) ``` annotation class ULong ``` **Platform and version requirements:** Native (1.3) #### [UShort](-u-short/index) ``` annotation class UShort ```
programming_docs
kotlin Int Int === [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Int](index) **Platform and version requirements:** Native (1.3) ``` annotation class Int ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` Int(value: Int) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: Int ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Int](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` Int(value: Int) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Int](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: Int ``` kotlin ULong ULong ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [ULong](index) **Platform and version requirements:** Native (1.3) ``` annotation class ULong ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` ULong(value: ULong) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: ULong ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [ULong](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` ULong(value: ULong) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [ULong](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: ULong ``` kotlin Short Short ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Short](index) **Platform and version requirements:** Native (1.3) ``` annotation class Short ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` Short(value: Short) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: Short ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Short](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` Short(value: Short) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Short](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: Short ``` kotlin UByte UByte ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UByte](index) **Platform and version requirements:** Native (1.3) ``` annotation class UByte ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` UByte(value: UByte) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: UByte ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UByte](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` UByte(value: UByte) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UByte](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: UByte ``` kotlin Float Float ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Float](index) **Platform and version requirements:** Native (1.3) ``` annotation class Float ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` Float(value: Float) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: Float ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Float](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` Float(value: Float) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Float](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: Float ``` kotlin String String ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [String](index) **Platform and version requirements:** Native (1.3) ``` annotation class String ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` String(value: String) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [String](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` String(value: String) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [String](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: String ``` kotlin Double Double ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Double](index) **Platform and version requirements:** Native (1.3) ``` annotation class Double ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` Double(value: Double) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: Double ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Double](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` Double(value: Double) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Double](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: Double ``` kotlin Byte Byte ==== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Byte](index) **Platform and version requirements:** Native (1.3) ``` annotation class Byte ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` Byte(value: Byte) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: Byte ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Byte](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` Byte(value: Byte) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Byte](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: Byte ``` kotlin UShort UShort ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UShort](index) **Platform and version requirements:** Native (1.3) ``` annotation class UShort ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` UShort(value: UShort) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: UShort ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UShort](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` UShort(value: UShort) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UShort](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: UShort ``` kotlin Long Long ==== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Long](index) **Platform and version requirements:** Native (1.3) ``` annotation class Long ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` Long(value: Long) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: Long ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Long](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` Long(value: Long) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [Long](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: Long ``` kotlin UInt UInt ==== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UInt](index) **Platform and version requirements:** Native (1.3) ``` annotation class UInt ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` UInt(value: UInt) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> ``` val value: UInt ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UInt](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` UInt(value: UInt) ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [ConstantValue](../index) / [UInt](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: UInt ``` kotlin CCall CCall ===== [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CCall](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) annotation class CCall ``` Annotations ----------- **Platform and version requirements:** Native (1.3) #### [Consumed](-consumed/index) ``` annotation class Consumed ``` **Platform and version requirements:** Native (1.3) #### [ConsumesReceiver](-consumes-receiver/index) ``` annotation class ConsumesReceiver ``` **Platform and version requirements:** Native (1.3) #### [CppClassConstructor](-cpp-class-constructor/index) ``` annotation class CppClassConstructor ``` **Platform and version requirements:** Native (1.3) #### [CString](-c-string/index) ``` annotation class CString ``` **Platform and version requirements:** Native (1.3) #### [ReturnsRetained](-returns-retained/index) ``` annotation class ReturnsRetained ``` **Platform and version requirements:** Native (1.3) #### [WCString](-w-c-string/index) ``` annotation class WCString ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` CCall(id: String) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <id> ``` val id: String ``` kotlin id id == [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CCall](index) / <id> **Platform and version requirements:** Native (1.3) ``` val id: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CCall](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` CCall(id: String) ``` kotlin CppClassConstructor CppClassConstructor =================== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [CppClassConstructor](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.CONSTRUCTOR]) annotation class CppClassConstructor ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` CppClassConstructor() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [CppClassConstructor](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` CppClassConstructor() ``` kotlin Consumed Consumed ======== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [Consumed](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.VALUE_PARAMETER]) annotation class Consumed ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` Consumed() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [Consumed](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` Consumed() ``` kotlin ConsumesReceiver ConsumesReceiver ================ [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [ConsumesReceiver](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) annotation class ConsumesReceiver ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` ConsumesReceiver() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [ConsumesReceiver](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` ConsumesReceiver() ``` kotlin WCString WCString ======== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [WCString](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.VALUE_PARAMETER]) annotation class WCString ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` WCString() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [WCString](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` WCString() ``` kotlin ReturnsRetained ReturnsRetained =============== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [ReturnsRetained](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) annotation class ReturnsRetained ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` ReturnsRetained() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [ReturnsRetained](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` ReturnsRetained() ``` kotlin CString CString ======= [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [CString](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.VALUE_PARAMETER]) annotation class CString ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` CString() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CCall](../index) / [CString](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` CString() ``` kotlin CStruct CStruct ======= [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CStruct](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.CLASS]) annotation class CStruct ``` Annotations ----------- **Platform and version requirements:** Native (1.3) #### [ArrayMemberAt](-array-member-at/index) ``` annotation class ArrayMemberAt ``` **Platform and version requirements:** Native (1.3) #### [BitField](-bit-field/index) ``` annotation class BitField ``` **Platform and version requirements:** Native (1.3) #### [CPlusPlusClass](-c-plus-plus-class/index) ``` annotation class CPlusPlusClass ``` **Platform and version requirements:** Native (1.3) #### [ManagedType](-managed-type/index) ``` annotation class ManagedType ``` **Platform and version requirements:** Native (1.3) #### [MemberAt](-member-at/index) ``` annotation class MemberAt ``` **Platform and version requirements:** Native (1.3) #### [VarType](-var-type/index) ``` annotation class VarType ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` CStruct(spelling: String) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <spelling> ``` val spelling: String ``` kotlin spelling spelling ======== [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CStruct](index) / <spelling> **Platform and version requirements:** Native (1.3) ``` val spelling: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlinx.cinterop.internal](../index) / [CStruct](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` CStruct(spelling: String) ``` kotlin ArrayMemberAt ArrayMemberAt ============= [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [ArrayMemberAt](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.PROPERTY_GETTER]) annotation class ArrayMemberAt ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` ArrayMemberAt(offset: Long) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <offset> ``` val offset: Long ```
programming_docs
kotlin offset offset ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [ArrayMemberAt](index) / <offset> **Platform and version requirements:** Native (1.3) ``` val offset: Long ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [ArrayMemberAt](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` ArrayMemberAt(offset: Long) ``` kotlin MemberAt MemberAt ======== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [MemberAt](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) annotation class MemberAt ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` MemberAt(offset: Long) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <offset> ``` val offset: Long ``` kotlin offset offset ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [MemberAt](index) / <offset> **Platform and version requirements:** Native (1.3) ``` val offset: Long ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [MemberAt](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` MemberAt(offset: Long) ``` kotlin size size ==== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [VarType](index) / <size> **Platform and version requirements:** Native (1.3) ``` val size: Long ``` kotlin VarType VarType ======= [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [VarType](index) **Platform and version requirements:** Native (1.3) ``` annotation class VarType ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` VarType(size: Long, align: Int) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <align> ``` val align: Int ``` **Platform and version requirements:** Native (1.3) #### <size> ``` val size: Long ``` kotlin align align ===== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [VarType](index) / <align> **Platform and version requirements:** Native (1.3) ``` val align: Int ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [VarType](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` VarType(size: Long, align: Int) ``` kotlin ManagedType ManagedType =========== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [ManagedType](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.CLASS]) annotation class ManagedType ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` ManagedType() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [ManagedType](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` ManagedType() ``` kotlin CPlusPlusClass CPlusPlusClass ============== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [CPlusPlusClass](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.CLASS]) annotation class CPlusPlusClass ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` CPlusPlusClass() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [CPlusPlusClass](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` CPlusPlusClass() ``` kotlin size size ==== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [BitField](index) / <size> **Platform and version requirements:** Native (1.3) ``` val size: Int ``` kotlin BitField BitField ======== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [BitField](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) annotation class BitField ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` BitField(offset: Long, size: Int) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <offset> ``` val offset: Long ``` **Platform and version requirements:** Native (1.3) #### <size> ``` val size: Int ``` kotlin offset offset ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [BitField](index) / <offset> **Platform and version requirements:** Native (1.3) ``` val offset: Long ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../../index) / [kotlinx.cinterop.internal](../../index) / [CStruct](../index) / [BitField](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` BitField(offset: Long, size: Int) ``` kotlin Package kotlin.enums Package kotlin.enums ==================== [kotlin-stdlib](../../../../../index) / [kotlin.enums](index) Types ----- **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [EnumEntries](-enum-entries) A specialized immutable implementation of [List](../kotlin.collections/-list/index#kotlin.collections.List) interface that contains all enum entries of the specified enum type [E](-enum-entries#E). [EnumEntries](-enum-entries) contains all enum entries in the order they are declared in the source code, consistently with the corresponding [Enum.ordinal](../kotlin/-enum/ordinal#kotlin.Enum%24ordinal) values. ``` sealed interface EnumEntries<E : Enum<E>> : List<E> ``` kotlin EnumEntries EnumEntries =========== [kotlin-stdlib](../../../../../index) / [kotlin.enums](index) / [EnumEntries](-enum-entries) **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) ``` @ExperimentalStdlibApi sealed interface EnumEntries<E : Enum<E>> :      List<E> ``` A specialized immutable implementation of [List](../kotlin.collections/-list/index#kotlin.collections.List) interface that contains all enum entries of the specified enum type [E](-enum-entries#E). [EnumEntries](-enum-entries) contains all enum entries in the order they are declared in the source code, consistently with the corresponding [Enum.ordinal](../kotlin/-enum/ordinal#kotlin.Enum%24ordinal) values. An instance of this interface can only be obtained from `EnumClass.entries` property. Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../kotlin.collections/indices) Returns an [IntRange](../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../kotlin.collections/last-index) Returns the index of the last item in the list or -1 if the list is empty. ``` val <T> List<T>.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../kotlin.collections/all) Returns `true` if all elements match the given [predicate](../kotlin.collections/all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../kotlin.collections/any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../kotlin.collections/any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../kotlin.collections/as-iterable) Returns this collection as an [Iterable](../kotlin.collections/-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asReversed](../kotlin.collections/as-reversed) Returns a reversed read-only view of the original List. All changes made in the original list will be reflected in the reversed one. ``` fun <T> List<T>.asReversed(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../kotlin.collections/as-sequence) Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../kotlin.collections/associate) Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../kotlin.collections/associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../kotlin.collections/associate-by) Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../kotlin.collections/associate-by-to) Populates and returns the [destination](../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../kotlin.collections/associate-to) Populates and returns the [destination](../kotlin.collections/associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../kotlin.collections/associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../kotlin.collections/associate-with) Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../kotlin.collections/associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../kotlin.collections/associate-with-to) Populates and returns the [destination](../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearch](../kotlin.collections/binary-search) Searches this list or its range for the provided [element](../kotlin.collections/binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](../kotlin.collections/binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for an element for which the given [comparison](../kotlin.collections/binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearchBy](../kotlin.collections/binary-search-by) Searches this list or its range for an element having the key returned by the specified [selector](../kotlin.collections/binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](../kotlin.collections/binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. ``` fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     selector: (T) -> K? ): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../kotlin.collections/chunked) Splits this collection into a list of lists each not exceeding the given [size](../kotlin.collections/chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../kotlin.collections/chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../kotlin.collections/chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../kotlin.collections/component1) Returns 1st *element* from the list. ``` operator fun <T> List<T>.component1(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../kotlin.collections/component2) Returns 2nd *element* from the list. ``` operator fun <T> List<T>.component2(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../kotlin.collections/component3) Returns 3rd *element* from the list. ``` operator fun <T> List<T>.component3(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../kotlin.collections/component4) Returns 4th *element* from the list. ``` operator fun <T> List<T>.component4(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../kotlin.collections/component5) Returns 5th *element* from the list. ``` operator fun <T> List<T>.component5(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../kotlin.collections/contains) Returns `true` if [element](../kotlin.collections/contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../kotlin.collections/contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../kotlin.collections/count) Returns the number of elements matching the given [predicate](../kotlin.collections/count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../kotlin.collections/distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../kotlin.collections/distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../kotlin.collections/drop) Returns a list containing all elements except first [n](../kotlin.collections/drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](../kotlin.collections/drop-last) Returns a list containing all elements except last [n](../kotlin.collections/drop-last#kotlin.collections%24dropLast(kotlin.collections.List((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](../kotlin.collections/drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](../kotlin.collections/drop-last-while#kotlin.collections%24dropLastWhile(kotlin.collections.List((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../kotlin.collections/drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../kotlin.collections/drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../kotlin.collections/element-at-or-else) Returns an element at the given [index](../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../kotlin.collections/filter) Returns a list containing only elements matching the given [predicate](../kotlin.collections/filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../kotlin.collections/filter-indexed) Returns a list containing only elements matching the given [predicate](../kotlin.collections/filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../kotlin.collections/filter-indexed-to) Appends all elements matching the given [predicate](../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../kotlin.collections/filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../kotlin.collections/filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../kotlin.collections/filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../kotlin.collections/filter-not) Returns a list containing all elements not matching the given [predicate](../kotlin.collections/filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../kotlin.collections/filter-not-to) Appends all elements not matching the given [predicate](../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../kotlin.collections/filter-to) Appends all elements matching the given [predicate](../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../kotlin.collections/find) Returns the first element matching the given [predicate](../kotlin.collections/find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../kotlin.collections/find-last) Returns the last element matching the given [predicate](../kotlin.collections/find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../kotlin.collections/first) Returns the first element matching the given [predicate](../kotlin.collections/first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../kotlin.collections/first-not-null-of) Returns the first non-null value produced by [transform](../kotlin.collections/first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../kotlin.collections/first-not-null-of-or-null) Returns the first non-null value produced by [transform](../kotlin.collections/first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../kotlin.collections/first-or-null) Returns the first element matching the given [predicate](../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../kotlin.collections/flat-map) Returns a single list of all elements yielded from results of [transform](../kotlin.collections/flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../kotlin.collections/flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../kotlin.collections/flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../kotlin.collections/flat-map-indexed-to) Appends all elements yielded from results of [transform](../kotlin.collections/flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../kotlin.collections/flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../kotlin.collections/flat-map-to) Appends all elements yielded from results of [transform](../kotlin.collections/flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../kotlin.collections/flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../kotlin.collections/flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../kotlin.collections/fold) Accumulates value starting with [initial](../kotlin.collections/fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../kotlin.collections/fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../kotlin.collections/fold-indexed) Accumulates value starting with [initial](../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](../kotlin.collections/fold-right) Accumulates value starting with [initial](../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](../kotlin.collections/fold-right-indexed) Accumulates value starting with [initial](../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../kotlin.collections/for-each) Performs the given [action](../kotlin.collections/for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../kotlin.collections/for-each-indexed) Performs the given [action](../kotlin.collections/for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../kotlin.collections/get-or-else) Returns an element at the given [index](../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](../kotlin.collections/get-or-null) Returns an element at the given [index](../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.getOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../kotlin.collections/group-by) Groups elements of the original collection by the key returned by the given [keySelector](../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../kotlin.collections/group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../kotlin.collections/grouping-by) Creates a [Grouping](../kotlin.collections/-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../kotlin.collections/grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../kotlin.collections/if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../kotlin.collections/if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../kotlin.collections/index-of) Returns first index of [element](../kotlin.collections/index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` Returns first index of [element](../kotlin.collections/index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../kotlin.collections/index-of-first) Returns index of the first element matching the given [predicate](../kotlin.collections/index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](../kotlin.collections/index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../kotlin.collections/index-of-last) Returns index of the last element matching the given [predicate](../kotlin.collections/index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](../kotlin.collections/index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../kotlin.collections/intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../kotlin.collections/is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../kotlin.collections/is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../kotlin.collections/join-to) Appends the string from all the elements separated using [separator](../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../kotlin.collections/join-to-string) Creates a string from all the elements separated using [separator](../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../kotlin.collections/last) Returns the last element matching the given [predicate](../kotlin.collections/last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` ``` fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../kotlin.collections/last-index-of) Returns last index of [element](../kotlin.collections/last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](../kotlin.collections/last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../kotlin.collections/last-or-null) Returns the last element matching the given [predicate](../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../kotlin.collections/map) Returns a list containing the results of applying the given [transform](../kotlin.collections/map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../kotlin.collections/map-indexed) Returns a list containing the results of applying the given [transform](../kotlin.collections/map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../kotlin.collections/map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../kotlin.collections/map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../kotlin.collections/map-indexed-not-null-to) Applies the given [transform](../kotlin.collections/map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../kotlin.collections/map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../kotlin.collections/map-indexed-to) Applies the given [transform](../kotlin.collections/map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../kotlin.collections/map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../kotlin.collections/map-not-null) Returns a list containing only the non-null results of applying the given [transform](../kotlin.collections/map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../kotlin.collections/map-not-null-to) Applies the given [transform](../kotlin.collections/map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../kotlin.collections/map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../kotlin.collections/map-to) Applies the given [transform](../kotlin.collections/map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../kotlin.collections/map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../kotlin.collections/max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../kotlin.collections/max-of) Returns the largest value among all values produced by [selector](../kotlin.collections/max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../kotlin.collections/max-of-or-null) Returns the largest value among all values produced by [selector](../kotlin.collections/max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../kotlin.collections/max-of-with) Returns the largest value according to the provided [comparator](../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../kotlin.collections/max-of-with-or-null) Returns the largest value according to the provided [comparator](../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../kotlin.collections/max-with) Returns the first element having the largest value according to the provided [comparator](../kotlin.collections/max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../kotlin.collections/max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../kotlin.collections/max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../kotlin.collections/min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../kotlin.collections/min-of) Returns the smallest value among all values produced by [selector](../kotlin.collections/min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../kotlin.collections/min-of-or-null) Returns the smallest value among all values produced by [selector](../kotlin.collections/min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../kotlin.collections/min-of-with) Returns the smallest value according to the provided [comparator](../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../kotlin.collections/min-of-with-or-null) Returns the smallest value according to the provided [comparator](../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../kotlin.collections/minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../kotlin.collections/minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../kotlin.collections/minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../kotlin.collections/minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../kotlin.collections/minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../kotlin.collections/minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../kotlin.collections/minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../kotlin.collections/min-with) Returns the first element having the smallest value according to the provided [comparator](../kotlin.collections/min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../kotlin.collections/min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../kotlin.collections/min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../kotlin.collections/none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../kotlin.collections/none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../kotlin.collections/on-each) Performs the given [action](../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../kotlin.collections/on-each-indexed) Performs the given [action](../kotlin.collections/on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../kotlin.collections/partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../kotlin.collections/partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../kotlin.collections/partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../kotlin.collections/plus) Returns a list containing all elements of the original collection and then the given [element](../kotlin.collections/plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../kotlin.collections/plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../kotlin.collections/plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../kotlin.collections/plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../kotlin.collections/plus-element) Returns a list containing all elements of the original collection and then the given [element](../kotlin.collections/plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../kotlin.collections/random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../kotlin.collections/random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../kotlin.collections/reduce) Accumulates value starting with the first element and applying [operation](../kotlin.collections/reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../kotlin.collections/reduce-indexed) Accumulates value starting with the first element and applying [operation](../kotlin.collections/reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../kotlin.collections/reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../kotlin.collections/reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../kotlin.collections/reduce-or-null) Accumulates value starting with the first element and applying [operation](../kotlin.collections/reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](../kotlin.collections/reduce-right) Accumulates value starting with the last element and applying [operation](../kotlin.collections/reduce-right#kotlin.collections%24reduceRight(kotlin.collections.List((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](../kotlin.collections/reduce-right-indexed) Accumulates value starting with the last element and applying [operation](../kotlin.collections/reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](../kotlin.collections/reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](../kotlin.collections/reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](../kotlin.collections/reduce-right-or-null) Accumulates value starting with the last element and applying [operation](../kotlin.collections/reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.collections.List((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../kotlin.collections/reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../kotlin.collections/running-fold) Returns a list containing successive accumulation values generated by applying [operation](../kotlin.collections/running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../kotlin.collections/running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../kotlin.collections/running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../kotlin.collections/running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../kotlin.collections/running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../kotlin.collections/running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../kotlin.collections/running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../kotlin.collections/running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../kotlin.collections/running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../kotlin.collections/scan) Returns a list containing successive accumulation values generated by applying [operation](../kotlin.collections/scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../kotlin.collections/scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../kotlin.collections/scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../kotlin.collections/scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../kotlin.collections/scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../kotlin.collections/shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../kotlin.collections/shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../kotlin.collections/single) Returns the single element matching the given [predicate](../kotlin.collections/single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../kotlin.collections/single-or-null) Returns the single element matching the given [predicate](../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [slice](../kotlin.collections/slice) Returns a list containing elements at indices in the specified [indices](../kotlin.collections/slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` Returns a list containing elements at specified [indices](../kotlin.collections/slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../kotlin.collections/sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../kotlin.collections/sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../kotlin.collections/sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../kotlin.collections/sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../kotlin.collections/sorted-with) Returns a list of all elements sorted according to the specified [comparator](../kotlin.collections/sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../kotlin.collections/subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../kotlin.collections/sum-by) Returns the sum of all values produced by [selector](../kotlin.collections/sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../kotlin.collections/sum-by-double) Returns the sum of all values produced by [selector](../kotlin.collections/sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [sumOf](../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../kotlin.collections/take) Returns a list containing first [n](../kotlin.collections/take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](../kotlin.collections/take-last) Returns a list containing last [n](../kotlin.collections/take-last#kotlin.collections%24takeLast(kotlin.collections.List((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](../kotlin.collections/take-last-while) Returns a list containing last elements satisfying the given [predicate](../kotlin.collections/take-last-while#kotlin.collections%24takeLastWhile(kotlin.collections.List((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../kotlin.collections/take-while) Returns a list containing first elements satisfying the given [predicate](../kotlin.collections/take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../kotlin.collections/to-collection) Appends all elements to the given [destination](../kotlin.collections/to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../kotlin.collections/to-hash-set) Returns a new [HashSet](../kotlin.collections/-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../kotlin.collections/to-list) Returns a [List](../kotlin.collections/-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../kotlin.collections/to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../kotlin.collections/to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../kotlin.collections/to-mutable-set) Returns a new [MutableSet](../kotlin.collections/-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../kotlin.collections/to-set) Returns a [Set](../kotlin.collections/-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../kotlin.collections/union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../kotlin.collections/unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../kotlin.collections/windowed) Returns a list of snapshots of the window of the given [size](../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../kotlin.collections/windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../kotlin.collections/with-index) Returns a lazy [Iterable](../kotlin.collections/-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../kotlin.collections/zip) Returns a list of pairs built from the elements of `this` collection and the [other](../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../kotlin.collections/zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../kotlin.collections/zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../kotlin.collections/zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ```
programming_docs
kotlin Package kotlin.internal Package kotlin.internal ======================= [kotlin-stdlib](../../../../../index) / [kotlin.internal](index) Annotations ----------- **Platform and version requirements:** Native (1.7) #### [IntrinsicConstEvaluation](-intrinsic-const-evaluation/index) When applied to a function or property, enables a compiler optimization that evaluates that function or property at compile-time and replaces calls to it with the computed result. ``` annotation class IntrinsicConstEvaluation ``` kotlin IntrinsicConstEvaluation IntrinsicConstEvaluation ======================== [kotlin-stdlib](../../../../../../index) / [kotlin.internal](../index) / [IntrinsicConstEvaluation](index) **Platform and version requirements:** Native (1.7) ``` @Target([AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY]) annotation class IntrinsicConstEvaluation ``` When applied to a function or property, enables a compiler optimization that evaluates that function or property at compile-time and replaces calls to it with the computed result. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) When applied to a function or property, enables a compiler optimization that evaluates that function or property at compile-time and replaces calls to it with the computed result. ``` IntrinsicConstEvaluation() ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotationClass](../../kotlin.jvm/annotation-class) Returns a [KClass](../../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance corresponding to the annotation type of this annotation. ``` val <T : Annotation> T.annotationClass: KClass<out T> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.internal](../index) / [IntrinsicConstEvaluation](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` IntrinsicConstEvaluation() ``` When applied to a function or property, enables a compiler optimization that evaluates that function or property at compile-time and replaces calls to it with the computed result. kotlin Package kotlin.jvm.optionals Package kotlin.jvm.optionals ============================ [kotlin-stdlib](../../../../../index) / [kotlin.jvm.optionals](index) Convenience extension functions for `java.util.Optional` to simplify Kotlin-Java interop. Extensions for External Classes ------------------------------- **Platform and version requirements:** JVM (1.8), JRE8 (1.8) #### [java.util.Optional](java.util.-optional/index) kotlin toList toList ====== [kotlin-stdlib](../../../../../../index) / [kotlin.jvm.optionals](../index) / [java.util.Optional](index) / [toList](to-list) **Platform and version requirements:** JVM (1.8), JRE8 (1.8) ``` fun <T : Any> Optional<out T>.toList(): List<T> ``` Returns a new read-only list of this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise an empty list. The returned list is serializable (JVM). kotlin Extensions for java.util.Optional Extensions for java.util.Optional ================================= [kotlin-stdlib](../../../../../../index) / [kotlin.jvm.optionals](../index) / [java.util.Optional](index) **Platform and version requirements:** JVM (1.8), JRE8 (1.8) #### [Any](-any) Returns this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise defaultValue. ``` fun <T> Optional<out T>.Any() ``` **Platform and version requirements:** JVM (1.8), JRE8 (1.8) #### [asSequence](as-sequence) Returns a new sequence for this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise an empty sequence. ``` fun <T : Any> Optional<out T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.8), JRE8 (1.8) #### [getOrNull](get-or-null) Returns this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise `null`. ``` fun <T : Any> Optional<T>.getOrNull(): T? ``` **Platform and version requirements:** JVM (1.8), JRE8 (1.8) #### [toCollection](to-collection) Appends this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value to the given [destination](to-collection#kotlin.jvm.optionals%24toCollection(java.util.Optional((kotlin.jvm.optionals.toCollection.T)),%20kotlin.jvm.optionals.toCollection.C)/destination) collection if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--). ``` fun <T : Any, C : MutableCollection<in T>> Optional<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.8), JRE8 (1.8) #### [toList](to-list) Returns a new read-only list of this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise an empty list. The returned list is serializable (JVM). ``` fun <T : Any> Optional<out T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.8), JRE8 (1.8) #### [toSet](to-set) Returns a new read-only set of this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise an empty set. The returned set is serializable (JVM). ``` fun <T : Any> Optional<out T>.toSet(): Set<T> ``` kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../../index) / [kotlin.jvm.optionals](../index) / [java.util.Optional](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.8), JRE8 (1.8) ``` fun <T : Any> Optional<out T>.asSequence(): Sequence<T> ``` Returns a new sequence for this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise an empty sequence. kotlin toCollection toCollection ============ [kotlin-stdlib](../../../../../../index) / [kotlin.jvm.optionals](../index) / [java.util.Optional](index) / [toCollection](to-collection) **Platform and version requirements:** JVM (1.8), JRE8 (1.8) ``` fun <T : Any, C : MutableCollection<in T>> Optional<T>.toCollection(     destination: C ): C ``` Appends this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value to the given [destination](to-collection#kotlin.jvm.optionals%24toCollection(java.util.Optional((kotlin.jvm.optionals.toCollection.T)),%20kotlin.jvm.optionals.toCollection.C)/destination) collection if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--). kotlin toSet toSet ===== [kotlin-stdlib](../../../../../../index) / [kotlin.jvm.optionals](../index) / [java.util.Optional](index) / [toSet](to-set) **Platform and version requirements:** JVM (1.8), JRE8 (1.8) ``` fun <T : Any> Optional<out T>.toSet(): Set<T> ``` Returns a new read-only set of this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise an empty set. The returned set is serializable (JVM). kotlin getOrNull getOrNull ========= [kotlin-stdlib](../../../../../../index) / [kotlin.jvm.optionals](../index) / [java.util.Optional](index) / [getOrNull](get-or-null) **Platform and version requirements:** JVM (1.8), JRE8 (1.8) ``` fun <T : Any> Optional<T>.getOrNull(): T? ``` Returns this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise `null`. kotlin Any Any === [kotlin-stdlib](../../../../../../index) / [kotlin.jvm.optionals](../index) / [java.util.Optional](index) / [Any](-any) **Platform and version requirements:** JVM (1.8), JRE8 (1.8) ``` fun <T> Optional<out T>.Any() ``` Returns this [Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)'s value if [present](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--), or otherwise defaultValue. kotlin javaType javaType ======== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [javaType](java-type) **Platform and version requirements:** JVM (1.0) ``` val KType.javaType: Type ``` Returns a Java [Type](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html) instance corresponding to the given Kotlin type. Note that one Kotlin type may correspond to different JVM types depending on where it appears. For example, [Unit](../kotlin/-unit/index#kotlin.Unit) corresponds to the JVM class [Unit](../kotlin/-unit/index#kotlin.Unit) when it's the type of a parameter, or to `void` when it's the return type of a function. kotlin reflect reflect ======= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / <reflect> **Platform and version requirements:** JVM (1.0) ``` @ExperimentalReflectionOnLambdas fun <R> Function<R>.reflect(): KFunction<R>? ``` This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance providing introspection capabilities for that lambda or function expression and its parameters. Not all features are currently supported, in particular KCallable.call and KCallable.callBy will fail at the moment. kotlin Package kotlin.reflect.jvm Package kotlin.reflect.jvm ========================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) Runtime API for interoperability between [Kotlin reflection](../../../../../docs/reflection) and Java reflection provided by `kotlin-reflect` library. Annotations ----------- **Platform and version requirements:** JVM (1.5) #### [ExperimentalReflectionOnLambdas](-experimental-reflection-on-lambdas/index) This annotation marks the experimental kotlin-reflect API that allows to approximate a Kotlin lambda or a function expression instance to a [KFunction](../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance. The behavior of this API may be changed or the API may be removed completely in any further release. ``` annotation class ExperimentalReflectionOnLambdas ``` Extensions for External Classes ------------------------------- **Platform and version requirements:** JVM (1.0) #### [java.lang.reflect.Constructor](java.lang.reflect.-constructor/index) **Platform and version requirements:** JVM (1.0) #### [java.lang.reflect.Field](java.lang.reflect.-field/index) **Platform and version requirements:** JVM (1.0) #### [java.lang.reflect.Method](java.lang.reflect.-method/index) Properties ---------- **Platform and version requirements:** JVM (1.0) #### [isAccessible](is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaConstructor](java-constructor) Returns a Java [Constructor](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Constructor.html) instance corresponding to the given Kotlin function, or `null` if this function is not a constructor or cannot be represented by a Java [Constructor](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Constructor.html). ``` val <T> KFunction<T>.javaConstructor: Constructor<T>? ``` **Platform and version requirements:** JVM (1.0) #### [javaField](java-field) Returns a Java [Field](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html) instance corresponding to the backing field of the given property, or `null` if the property has no backing field. ``` val KProperty<*>.javaField: Field? ``` **Platform and version requirements:** JVM (1.0) #### [javaGetter](java-getter) Returns a Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html) instance corresponding to the getter of the given property, or `null` if the property has no getter, for example in case of a simple private `val` in a class. ``` val KProperty<*>.javaGetter: Method? ``` **Platform and version requirements:** JVM (1.0) #### [javaMethod](java-method) Returns a Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html) instance corresponding to the given Kotlin function, or `null` if this function is a constructor or cannot be represented by a Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html). ``` val KFunction<*>.javaMethod: Method? ``` **Platform and version requirements:** JVM (1.0) #### [javaSetter](java-setter) Returns a Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html) instance corresponding to the setter of the given mutable property, or `null` if the property has no setter, for example in case of a simple private `var` in a class. ``` val KMutableProperty<*>.javaSetter: Method? ``` **Platform and version requirements:** JVM (1.0) #### [javaType](java-type) Returns a Java [Type](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html) instance corresponding to the given Kotlin type. Note that one Kotlin type may correspond to different JVM types depending on where it appears. For example, [Unit](../kotlin/-unit/index#kotlin.Unit) corresponds to the JVM class [Unit](../kotlin/-unit/index#kotlin.Unit) when it's the type of a parameter, or to `void` when it's the return type of a function. ``` val KType.javaType: Type ``` **Platform and version requirements:** JVM (1.1) #### [jvmErasure](jvm-erasure) Returns the [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance representing the runtime class to which this type is erased to on JVM. ``` val KType.jvmErasure: KClass<*> ``` **Platform and version requirements:** JVM (1.0) #### [jvmName](jvm-name) Returns the JVM name of the class represented by this [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance. ``` val KClass<*>.jvmName: String ``` Functions --------- **Platform and version requirements:** JVM (1.0) #### <reflect> This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance providing introspection capabilities for that lambda or function expression and its parameters. Not all features are currently supported, in particular KCallable.call and KCallable.callBy will fail at the moment. ``` fun <R> Function<R>.reflect(): KFunction<R>? ``` kotlin javaField javaField ========= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [javaField](java-field) **Platform and version requirements:** JVM (1.0) ``` val KProperty<*>.javaField: Field? ``` Returns a Java [Field](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html) instance corresponding to the backing field of the given property, or `null` if the property has no backing field. kotlin javaMethod javaMethod ========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [javaMethod](java-method) **Platform and version requirements:** JVM (1.0) ``` val KFunction<*>.javaMethod: Method? ``` Returns a Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html) instance corresponding to the given Kotlin function, or `null` if this function is a constructor or cannot be represented by a Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html). kotlin javaConstructor javaConstructor =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [javaConstructor](java-constructor) **Platform and version requirements:** JVM (1.0) ``` val <T> KFunction<T>.javaConstructor: Constructor<T>? ``` Returns a Java [Constructor](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Constructor.html) instance corresponding to the given Kotlin function, or `null` if this function is not a constructor or cannot be represented by a Java [Constructor](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Constructor.html). kotlin jvmErasure jvmErasure ========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [jvmErasure](jvm-erasure) **Platform and version requirements:** JVM (1.1) ``` val KType.jvmErasure: KClass<*> ``` Returns the [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance representing the runtime class to which this type is erased to on JVM. kotlin javaGetter javaGetter ========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [javaGetter](java-getter) **Platform and version requirements:** JVM (1.0) ``` val KProperty<*>.javaGetter: Method? ``` Returns a Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html) instance corresponding to the getter of the given property, or `null` if the property has no getter, for example in case of a simple private `val` in a class. kotlin jvmName jvmName ======= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [jvmName](jvm-name) **Platform and version requirements:** JVM (1.0) ``` val KClass<*>.jvmName: String ``` Returns the JVM name of the class represented by this [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance. **See Also** [java.lang.Class.getName](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getName--) kotlin isAccessible isAccessible ============ [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [isAccessible](is-accessible) **Platform and version requirements:** JVM (1.0) ``` var KCallable<*>.isAccessible: Boolean ``` Provides a way to suppress JVM access checks for a callable. **Getter** returns `true` if JVM access checks are suppressed for this callable object. For a property, that means that all its accessors (getter, and setter for `var` properties) are accessible. **Setter** if set to `true`, suppresses JVM access checks for this callable object. For a property, both accessors are made accessible. **See Also** [java.lang.reflect.AccessibleObject](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AccessibleObject.html) kotlin javaSetter javaSetter ========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.jvm](index) / [javaSetter](java-setter) **Platform and version requirements:** JVM (1.0) ``` val KMutableProperty<*>.javaSetter: Method? ``` Returns a Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html) instance corresponding to the setter of the given mutable property, or `null` if the property has no setter, for example in case of a simple private `var` in a class. kotlin Extensions for java.lang.reflect.Method Extensions for java.lang.reflect.Method ======================================= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.jvm](../index) / [java.lang.reflect.Method](index) **Platform and version requirements:** JVM (1.0) #### [kotlinFunction](kotlin-function) Returns a [KFunction](../../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance corresponding to the given Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html) instance, or `null` if this method cannot be represented by a Kotlin function. ``` val Method.kotlinFunction: KFunction<*>? ```
programming_docs
kotlin kotlinFunction kotlinFunction ============== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.jvm](../index) / [java.lang.reflect.Method](index) / [kotlinFunction](kotlin-function) **Platform and version requirements:** JVM (1.0) ``` val Method.kotlinFunction: KFunction<*>? ``` Returns a [KFunction](../../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance corresponding to the given Java [Method](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html) instance, or `null` if this method cannot be represented by a Kotlin function. kotlin ExperimentalReflectionOnLambdas ExperimentalReflectionOnLambdas =============================== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.jvm](../index) / [ExperimentalReflectionOnLambdas](index) **Platform and version requirements:** JVM (1.5) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPEALIAS]) annotation class ExperimentalReflectionOnLambdas ``` This annotation marks the experimental kotlin-reflect API that allows to approximate a Kotlin lambda or a function expression instance to a [KFunction](../../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance. The behavior of this API may be changed or the API may be removed completely in any further release. Any usage of a declaration annotated with `@ExperimentalReflectionOnLambdas` should be accepted either by annotating that usage with the OptIn annotation, e.g. `@OptIn(ExperimentalReflectionOnLambdas::class)`, or by using the compiler argument `-opt-in=kotlin.reflect.jvm.ExperimentalReflectionOnLambdas`. Constructors ------------ **Platform and version requirements:** JVM (1.0) #### [<init>](-init-) This annotation marks the experimental kotlin-reflect API that allows to approximate a Kotlin lambda or a function expression instance to a [KFunction](../../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance. The behavior of this API may be changed or the API may be removed completely in any further release. ``` ExperimentalReflectionOnLambdas() ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotationClass](../../kotlin.jvm/annotation-class) Returns a [KClass](../../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance corresponding to the annotation type of this annotation. ``` val <T : Annotation> T.annotationClass: KClass<out T> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.jvm](../index) / [ExperimentalReflectionOnLambdas](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0) ``` ExperimentalReflectionOnLambdas() ``` This annotation marks the experimental kotlin-reflect API that allows to approximate a Kotlin lambda or a function expression instance to a [KFunction](../../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance. The behavior of this API may be changed or the API may be removed completely in any further release. Any usage of a declaration annotated with `@ExperimentalReflectionOnLambdas` should be accepted either by annotating that usage with the OptIn annotation, e.g. `@OptIn(ExperimentalReflectionOnLambdas::class)`, or by using the compiler argument `-opt-in=kotlin.reflect.jvm.ExperimentalReflectionOnLambdas`. kotlin Extensions for java.lang.reflect.Constructor Extensions for java.lang.reflect.Constructor ============================================ [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.jvm](../index) / [java.lang.reflect.Constructor](index) **Platform and version requirements:** JVM (1.0) #### [kotlinFunction](kotlin-function) Returns a [KFunction](../../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance corresponding to the given Java [Constructor](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Constructor.html) instance, or `null` if this constructor cannot be represented by a Kotlin function (for example, if it is a synthetic constructor). ``` val <T : Any> Constructor<T>.kotlinFunction: KFunction<T>? ``` kotlin kotlinFunction kotlinFunction ============== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.jvm](../index) / [java.lang.reflect.Constructor](index) / [kotlinFunction](kotlin-function) **Platform and version requirements:** JVM (1.0) ``` val <T : Any> Constructor<T>.kotlinFunction: KFunction<T>? ``` Returns a [KFunction](../../kotlin.reflect/-k-function/index#kotlin.reflect.KFunction) instance corresponding to the given Java [Constructor](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Constructor.html) instance, or `null` if this constructor cannot be represented by a Kotlin function (for example, if it is a synthetic constructor). kotlin Extensions for java.lang.reflect.Field Extensions for java.lang.reflect.Field ====================================== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.jvm](../index) / [java.lang.reflect.Field](index) **Platform and version requirements:** JVM (1.0) #### [kotlinProperty](kotlin-property) Returns a [KProperty](../../kotlin.reflect/-k-property/index#kotlin.reflect.KProperty) instance corresponding to the given Java [Field](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html) instance, or `null` if this field cannot be represented by a Kotlin property (for example, if it is a synthetic field). ``` val Field.kotlinProperty: KProperty<*>? ``` kotlin kotlinProperty kotlinProperty ============== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.jvm](../index) / [java.lang.reflect.Field](index) / [kotlinProperty](kotlin-property) **Platform and version requirements:** JVM (1.0) ``` val Field.kotlinProperty: KProperty<*>? ``` Returns a [KProperty](../../kotlin.reflect/-k-property/index#kotlin.reflect.KProperty) instance corresponding to the given Java [Field](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html) instance, or `null` if this field cannot be represented by a Kotlin property (for example, if it is a synthetic field). kotlin sortedWith sortedWith ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedWith](sorted-with) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` Returns a list of all elements sorted according to the specified [comparator](sorted-with#kotlin.collections%24sortedWith(kotlin.Array((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.sortedWith(     comparator: Comparator<in Byte> ): List<Byte> ``` ``` fun ShortArray.sortedWith(     comparator: Comparator<in Short> ): List<Short> ``` ``` fun IntArray.sortedWith(     comparator: Comparator<in Int> ): List<Int> ``` ``` fun LongArray.sortedWith(     comparator: Comparator<in Long> ): List<Long> ``` ``` fun FloatArray.sortedWith(     comparator: Comparator<in Float> ): List<Float> ``` ``` fun DoubleArray.sortedWith(     comparator: Comparator<in Double> ): List<Double> ``` ``` fun BooleanArray.sortedWith(     comparator: Comparator<in Boolean> ): List<Boolean> ``` ``` fun CharArray.sortedWith(     comparator: Comparator<in Char> ): List<Char> ``` Returns a list of all elements sorted according to the specified [comparator](sorted-with#kotlin.collections%24sortedWith(kotlin.ByteArray,%20kotlin.Comparator((kotlin.Byte)))/comparator). kotlin plusAssign plusAssign ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [plusAssign](plus-assign) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pair: Pair<K, V>) ``` Appends or replaces the given [pair](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/pair) in this mutable map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Iterable<Pair<K, V>>) ``` Appends or replaces all pairs from the given collection of [pairs](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Array<out Pair<K, V>>) ``` Appends or replaces all pairs from the given array of [pairs](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Sequence<Pair<K, V>>) ``` Appends or replaces all pairs from the given sequence of [pairs](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     map: Map<K, V>) ``` Appends or replaces all entries from the given [map](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Map((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/map) in this mutable map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds the specified [element](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` Adds all elements of the given [elements](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. kotlin joinTo joinTo ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [joinTo](join-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, A : Appendable> Array<out T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> ByteArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Byte) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> ShortArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Short) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> IntArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Int) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> LongArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Long) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> FloatArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Float) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> DoubleArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Double) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> BooleanArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Boolean) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> CharArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Char) -> CharSequence)? = null ): A ``` ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` Appends the string from all the elements separated using [separator](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. If the collection could be huge, you can specify a non-negative value of [limit](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/limit), in which case only the first [limit](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/limit) elements will be appended, followed by the [truncated](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/truncated) string (which defaults to "..."). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sb = StringBuilder("An existing string and a list: ") val numbers = listOf(1, 2, 3) println(numbers.joinTo(sb, prefix = "[", postfix = "]").toString()) // An existing string and a list: [1, 2, 3] val lotOfNumbers: Iterable<Int> = 1..100 val firstNumbers = StringBuilder("First five numbers: ") println(lotOfNumbers.joinTo(firstNumbers, limit = 5).toString()) // First five numbers: 1, 2, 3, 4, 5, ... //sampleEnd } ``` kotlin foldIndexed foldIndexed =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [foldIndexed](fold-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Array<out T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` ``` inline fun <R> ByteArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> R ): R ``` ``` inline fun <R> ShortArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> R ): R ``` ``` inline fun <R> IntArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> R ): R ``` ``` inline fun <R> LongArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> R ): R ``` ``` inline fun <R> FloatArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> R ): R ``` ``` inline fun <R> DoubleArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> R ): R ``` ``` inline fun <R> BooleanArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> R ): R ``` ``` inline fun <R> CharArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UShort) -> R ): R ``` Accumulates value starting with [initial](fold-indexed#kotlin.collections%24foldIndexed(kotlin.Array((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](fold-indexed#kotlin.collections%24foldIndexed(kotlin.Array((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. Returns the specified [initial](fold-indexed#kotlin.collections%24foldIndexed(kotlin.Array((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value if the array is empty. Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` Accumulates value starting with [initial](fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. Returns the specified [initial](fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value if the collection is empty. Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value.
programming_docs
kotlin sort sort ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <sort> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun IntArray.sort() ``` ``` fun LongArray.sort() ``` ``` fun ByteArray.sort() ``` ``` fun ShortArray.sort() ``` ``` fun DoubleArray.sort() ``` ``` fun FloatArray.sort() ``` ``` fun CharArray.sort() ``` Sorts the array in-place. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val intArray = intArrayOf(4, 3, 2, 1) // before sorting println(intArray.joinToString()) // 4, 3, 2, 1 intArray.sort() // after sorting println(intArray.joinToString()) // 1, 2, 3, 4 //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> Array<out T>.sort() ``` Sorts the array in-place according to the natural order of its elements. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart class Person(val firstName: String, val lastName: String) : Comparable<Person> { override fun compareTo(other: Person): Int = this.lastName.compareTo(other.lastName) override fun toString(): String = "$firstName $lastName" } val people = arrayOf( Person("Ragnar", "Lodbrok"), Person("Bjorn", "Ironside"), Person("Sweyn", "Forkbeard") ) // before sorting println(people.joinToString()) // Ragnar Lodbrok, Bjorn Ironside, Sweyn Forkbeard people.sort() // after sorting println(people.joinToString()) // Sweyn Forkbeard, Bjorn Ironside, Ragnar Lodbrok //sampleEnd } ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Comparable<T>> Array<out T>.sort(     fromIndex: Int = 0,     toIndex: Int = size) ``` Sorts a range in the array in-place. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart class Person(val firstName: String, val lastName: String) : Comparable<Person> { override fun compareTo(other: Person): Int = this.lastName.compareTo(other.lastName) override fun toString(): String = "$firstName $lastName" } val people = arrayOf( Person("Ragnar", "Lodbrok"), Person("Bjorn", "Ironside"), Person("Sweyn", "Forkbeard") ) // before sorting println(people.joinToString()) // Ragnar Lodbrok, Bjorn Ironside, Sweyn Forkbeard people.sort(0, 2) // after sorting println(people.joinToString()) // Bjorn Ironside, Ragnar Lodbrok, Sweyn Forkbeard //sampleEnd } ``` Parameters ---------- `fromIndex` - the start of the range (inclusive) to sort, 0 by default. `toIndex` - the end of the range (exclusive) to sort, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](sort#kotlin.collections%24sort(kotlin.Array((kotlin.collections.sort.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](sort#kotlin.collections%24sort(kotlin.Array((kotlin.collections.sort.T)),%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](sort#kotlin.collections%24sort(kotlin.Array((kotlin.collections.sort.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](sort#kotlin.collections%24sort(kotlin.Array((kotlin.collections.sort.T)),%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` Sorts a range in the array in-place. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val intArray = intArrayOf(4, 3, 2, 1) // before sorting println(intArray.joinToString()) // 4, 3, 2, 1 intArray.sort(0, 3) // after sorting println(intArray.joinToString()) // 2, 3, 4, 1 //sampleEnd } ``` Parameters ---------- `fromIndex` - the start of the range (inclusive) to sort, 0 by default. `toIndex` - the end of the range (exclusive) to sort, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](sort#kotlin.collections%24sort(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](sort#kotlin.collections%24sort(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](sort#kotlin.collections%24sort(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](sort#kotlin.collections%24sort(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.sort() ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sort() ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sort() ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sort() ``` Sorts the array in-place. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val intArray = intArrayOf(4, 3, 2, 1) // before sorting println(intArray.joinToString()) // 4, 3, 2, 1 intArray.sort() // after sorting println(intArray.joinToString()) // 1, 2, 3, 4 //sampleEnd } ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @ExperimentalUnsignedTypes fun UIntArray.sort(     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sort(     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sort(     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sort(     fromIndex: Int = 0,     toIndex: Int = size) ``` Sorts a range in the array in-place. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val intArray = intArrayOf(4, 3, 2, 1) // before sorting println(intArray.joinToString()) // 4, 3, 2, 1 intArray.sort(0, 3) // after sorting println(intArray.joinToString()) // 2, 3, 4, 1 //sampleEnd } ``` Parameters ---------- `fromIndex` - the start of the range (inclusive) to sort, 0 by default. `toIndex` - the end of the range (exclusive) to sort, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](sort#kotlin.collections%24sort(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](sort#kotlin.collections%24sort(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](sort#kotlin.collections%24sort(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](sort#kotlin.collections%24sort(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.0), JS (1.0) ``` fun <T : Comparable<T>> MutableList<T>.sort() ``` Sorts elements in the list in-place according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val mutableList = mutableListOf(4, 3, 2, 1) // before sorting println(mutableList.joinToString()) // 4, 3, 2, 1 mutableList.sort() // after sorting println(mutableList.joinToString()) // 1, 2, 3, 4 //sampleEnd } ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> MutableList<T>.sort(comparator: Comparator<in T>) ``` **Deprecated:** Use sortWith(comparator) instead. ``` inline fun <T> MutableList<T>.sort(comparison: (T, T) -> Int) ``` **Deprecated:** Use sortWith(Comparator(comparison)) instead. **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.6") fun <T> Array<out T>.sort(     comparison: (a: T, b: T) -> Int) ``` **Deprecated:** Use sortWith instead Sorts the array in-place according to the order specified by the given [comparison](sort#kotlin.collections%24sort(kotlin.Array((kotlin.collections.sort.T)),%20kotlin.Function2((kotlin.collections.sort.T,%20,%20kotlin.Int)))/comparison) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.6") inline fun ByteArray.sort(     noinline comparison: (a: Byte, b: Byte) -> Int) ``` **Deprecated:** Use other sorting functions from the Standard Library ``` @DeprecatedSinceKotlin("1.6") inline fun ShortArray.sort(     noinline comparison: (a: Short, b: Short) -> Int) ``` **Deprecated:** Use other sorting functions from the Standard Library ``` @DeprecatedSinceKotlin("1.6") inline fun IntArray.sort(     noinline comparison: (a: Int, b: Int) -> Int) ``` **Deprecated:** Use other sorting functions from the Standard Library ``` @DeprecatedSinceKotlin("1.6") inline fun LongArray.sort(     noinline comparison: (a: Long, b: Long) -> Int) ``` **Deprecated:** Use other sorting functions from the Standard Library ``` @DeprecatedSinceKotlin("1.6") inline fun FloatArray.sort(     noinline comparison: (a: Float, b: Float) -> Int) ``` **Deprecated:** Use other sorting functions from the Standard Library ``` @DeprecatedSinceKotlin("1.6") inline fun DoubleArray.sort(     noinline comparison: (a: Double, b: Double) -> Int) ``` **Deprecated:** Use other sorting functions from the Standard Library ``` @DeprecatedSinceKotlin("1.6") inline fun CharArray.sort(     noinline comparison: (a: Char, b: Char) -> Int) ``` **Deprecated:** Use other sorting functions from the Standard Library Sorts the array in-place according to the order specified by the given [comparison](sort#kotlin.collections%24sort(kotlin.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20kotlin.Int)))/comparison) function. kotlin all all === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <all> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.all(     predicate: (T) -> Boolean ): Boolean ``` ``` inline fun ByteArray.all(     predicate: (Byte) -> Boolean ): Boolean ``` ``` inline fun ShortArray.all(     predicate: (Short) -> Boolean ): Boolean ``` ``` inline fun IntArray.all(predicate: (Int) -> Boolean): Boolean ``` ``` inline fun LongArray.all(     predicate: (Long) -> Boolean ): Boolean ``` ``` inline fun FloatArray.all(     predicate: (Float) -> Boolean ): Boolean ``` ``` inline fun DoubleArray.all(     predicate: (Double) -> Boolean ): Boolean ``` ``` inline fun BooleanArray.all(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.all(     predicate: (Char) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.all(     predicate: (UInt) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.all(     predicate: (ULong) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.all(     predicate: (UByte) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.all(     predicate: (UShort) -> Boolean ): Boolean ``` Returns `true` if all elements match the given [predicate](all#kotlin.collections%24all(kotlin.Array((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). Note that if the array contains no elements, the function returns `true` because there are no elements in it that *do not* match the predicate. See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.all { isEven(it) } is ${zeroToTen.all { isEven(it) }}") // false println("zeroToTen.all(isEven) is ${zeroToTen.all(isEven)}") // false val evens = zeroToTen.map { it * 2 } println("evens.all { isEven(it) } is ${evens.all { isEven(it) }}") // true val emptyList = emptyList<Int>() println("emptyList.all { false } is ${emptyList.all { false }}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Iterable<T>.all(     predicate: (T) -> Boolean ): Boolean ``` Returns `true` if all elements match the given [predicate](all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). Note that if the collection contains no elements, the function returns `true` because there are no elements in it that *do not* match the predicate. See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.all { isEven(it) } is ${zeroToTen.all { isEven(it) }}") // false println("zeroToTen.all(isEven) is ${zeroToTen.all(isEven)}") // false val evens = zeroToTen.map { it * 2 } println("evens.all { isEven(it) } is ${evens.all { isEven(it) }}") // true val emptyList = emptyList<Int>() println("emptyList.all { false } is ${emptyList.all { false }}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.all(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` Returns `true` if all entries match the given [predicate](all#kotlin.collections%24all(kotlin.collections.Map((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Boolean)))/predicate). Note that if the map contains no entries, the function returns `true` because there are no entries in it that *do not* match the predicate. See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.all { isEven(it) } is ${zeroToTen.all { isEven(it) }}") // false println("zeroToTen.all(isEven) is ${zeroToTen.all(isEven)}") // false val evens = zeroToTen.map { it * 2 } println("evens.all { isEven(it) } is ${evens.all { isEven(it) }}") // true val emptyList = emptyList<Int>() println("emptyList.all { false } is ${emptyList.all { false }}") // true //sampleEnd } ``` kotlin reduceIndexedOrNull reduceIndexedOrNull =================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reduceIndexedOrNull](reduce-indexed-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Array<out T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` ``` inline fun ByteArray.reduceIndexedOrNull(     operation: (index: Int, acc: Byte, Byte) -> Byte ): Byte? ``` ``` inline fun ShortArray.reduceIndexedOrNull(     operation: (index: Int, acc: Short, Short) -> Short ): Short? ``` ``` inline fun IntArray.reduceIndexedOrNull(     operation: (index: Int, acc: Int, Int) -> Int ): Int? ``` ``` inline fun LongArray.reduceIndexedOrNull(     operation: (index: Int, acc: Long, Long) -> Long ): Long? ``` ``` inline fun FloatArray.reduceIndexedOrNull(     operation: (index: Int, acc: Float, Float) -> Float ): Float? ``` ``` inline fun DoubleArray.reduceIndexedOrNull(     operation: (index: Int, acc: Double, Double) -> Double ): Double? ``` ``` inline fun BooleanArray.reduceIndexedOrNull(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.reduceIndexedOrNull(     operation: (index: Int, acc: Char, Char) -> Char ): Char? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.reduceIndexedOrNull(     operation: (index: Int, acc: UInt, UInt) -> UInt ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.reduceIndexedOrNull(     operation: (index: Int, acc: ULong, ULong) -> ULong ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.reduceIndexedOrNull(     operation: (index: Int, acc: UByte, UByte) -> UByte ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.reduceIndexedOrNull(     operation: (index: Int, acc: UShort, UShort) -> UShort ): UShort? ``` Accumulates value starting with the first element and applying [operation](reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.Array((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. Returns `null` if the array is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceOrNull { acc, string -> acc + string }) // abcd println(strings.reduceIndexedOrNull { index, acc, string -> acc + string + index }) // ab1c2d3 println(emptyList<String>().reduceOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` Accumulates value starting with the first element and applying [operation](reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. Returns `null` if the collection is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceOrNull { acc, string -> acc + string }) // abcd println(strings.reduceIndexedOrNull { index, acc, string -> acc + string + index }) // ab1c2d3 println(emptyList<String>().reduceOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. kotlin single single ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <single> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.single(): T ``` ``` fun ByteArray.single(): Byte ``` ``` fun ShortArray.single(): Short ``` ``` fun IntArray.single(): Int ``` ``` fun LongArray.single(): Long ``` ``` fun FloatArray.single(): Float ``` ``` fun DoubleArray.single(): Double ``` ``` fun BooleanArray.single(): Boolean ``` ``` fun CharArray.single(): Char ``` ``` @ExperimentalUnsignedTypes fun UIntArray.single(): UInt ``` ``` @ExperimentalUnsignedTypes fun ULongArray.single(): ULong ``` ``` @ExperimentalUnsignedTypes fun UByteArray.single(): UByte ``` ``` @ExperimentalUnsignedTypes fun UShortArray.single(): UShort ``` Returns the single element, or throws an exception if the array is empty or has more than one element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.single(     predicate: (T) -> Boolean ): T ``` ``` inline fun ByteArray.single(     predicate: (Byte) -> Boolean ): Byte ``` ``` inline fun ShortArray.single(     predicate: (Short) -> Boolean ): Short ``` ``` inline fun IntArray.single(predicate: (Int) -> Boolean): Int ``` ``` inline fun LongArray.single(     predicate: (Long) -> Boolean ): Long ``` ``` inline fun FloatArray.single(     predicate: (Float) -> Boolean ): Float ``` ``` inline fun DoubleArray.single(     predicate: (Double) -> Boolean ): Double ``` ``` inline fun BooleanArray.single(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.single(     predicate: (Char) -> Boolean ): Char ``` ``` inline fun <T> Iterable<T>.single(     predicate: (T) -> Boolean ): T ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.single(     predicate: (UInt) -> Boolean ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.single(     predicate: (ULong) -> Boolean ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.single(     predicate: (UByte) -> Boolean ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.single(     predicate: (UShort) -> Boolean ): UShort ``` Returns the single element matching the given [predicate](single#kotlin.collections%24single(kotlin.Array((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.single(): T ``` Returns the single element, or throws an exception if the collection is empty or has more than one element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.single(): T ``` Returns the single element, or throws an exception if the list is empty or has more than one element.
programming_docs
kotlin reduceOrNull reduceOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reduceOrNull](reduce-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Array<out T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` ``` inline fun ByteArray.reduceOrNull(     operation: (acc: Byte, Byte) -> Byte ): Byte? ``` ``` inline fun ShortArray.reduceOrNull(     operation: (acc: Short, Short) -> Short ): Short? ``` ``` inline fun IntArray.reduceOrNull(     operation: (acc: Int, Int) -> Int ): Int? ``` ``` inline fun LongArray.reduceOrNull(     operation: (acc: Long, Long) -> Long ): Long? ``` ``` inline fun FloatArray.reduceOrNull(     operation: (acc: Float, Float) -> Float ): Float? ``` ``` inline fun DoubleArray.reduceOrNull(     operation: (acc: Double, Double) -> Double ): Double? ``` ``` inline fun BooleanArray.reduceOrNull(     operation: (acc: Boolean, Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.reduceOrNull(     operation: (acc: Char, Char) -> Char ): Char? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.reduceOrNull(     operation: (acc: UInt, UInt) -> UInt ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.reduceOrNull(     operation: (acc: ULong, ULong) -> ULong ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.reduceOrNull(     operation: (acc: UByte, UByte) -> UByte ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.reduceOrNull(     operation: (acc: UShort, UShort) -> UShort ): UShort? ``` Accumulates value starting with the first element and applying [operation](reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.Array((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. Returns `null` if the array is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceOrNull { acc, string -> acc + string }) // abcd println(strings.reduceIndexedOrNull { index, acc, string -> acc + string + index }) // ab1c2d3 println(emptyList<String>().reduceOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` Accumulates value starting with the first element and applying [operation](reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. Returns `null` if the collection is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceOrNull { acc, string -> acc + string }) // abcd println(strings.reduceIndexedOrNull { index, acc, string -> acc + string + index }) // ab1c2d3 println(emptyList<String>().reduceOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. kotlin eachCountTo eachCountTo =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [eachCountTo](each-count-to) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T, K, M : MutableMap<in K, Int>> Grouping<T, K>.eachCountTo(     destination: M ): M ``` Groups elements from the [Grouping](-grouping/index) source by key and counts elements in each group to the given [destination](each-count-to#kotlin.collections%24eachCountTo(kotlin.collections.Grouping((kotlin.collections.eachCountTo.T,%20kotlin.collections.eachCountTo.K)),%20kotlin.collections.eachCountTo.M)/destination) map. If the [destination](each-count-to#kotlin.collections%24eachCountTo(kotlin.collections.Grouping((kotlin.collections.eachCountTo.T,%20kotlin.collections.eachCountTo.K)),%20kotlin.collections.eachCountTo.M)/destination) map already has a value corresponding to the key of some group, that value is used as an initial value of the counter for that group. ``` fun main(args: Array<String>) { //sampleStart val words = "one two three four five six seven eight nine ten".split(' ') val frequenciesByFirstChar = words.groupingBy { it.first() }.eachCount() println("Counting first letters:") println(frequenciesByFirstChar) // {o=1, t=3, f=2, s=2, e=1, n=1} val moreWords = "eleven twelve".split(' ') val moreFrequencies = moreWords.groupingBy { it.first() }.eachCountTo(frequenciesByFirstChar.toMutableMap()) println(moreFrequencies) // {o=1, t=4, f=2, s=2, e=2, n=1} //sampleEnd } ``` **Return** the [destination](each-count-to#kotlin.collections%24eachCountTo(kotlin.collections.Grouping((kotlin.collections.eachCountTo.T,%20kotlin.collections.eachCountTo.K)),%20kotlin.collections.eachCountTo.M)/destination) map associating the key of each group with the count of elements in the group. kotlin runningReduce runningReduce ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [runningReduce](running-reduce) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Array<out T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.Array((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. Note that `acc` value passed to [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.Array((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and the element, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun ByteArray.runningReduce(     operation: (acc: Byte, Byte) -> Byte ): List<Byte> ``` ``` inline fun ShortArray.runningReduce(     operation: (acc: Short, Short) -> Short ): List<Short> ``` ``` inline fun IntArray.runningReduce(     operation: (acc: Int, Int) -> Int ): List<Int> ``` ``` inline fun LongArray.runningReduce(     operation: (acc: Long, Long) -> Long ): List<Long> ``` ``` inline fun FloatArray.runningReduce(     operation: (acc: Float, Float) -> Float ): List<Float> ``` ``` inline fun DoubleArray.runningReduce(     operation: (acc: Double, Double) -> Double ): List<Double> ``` ``` inline fun BooleanArray.runningReduce(     operation: (acc: Boolean, Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.runningReduce(     operation: (acc: Char, Char) -> Char ): List<Char> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. Note that `acc` value passed to [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and the element, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @ExperimentalUnsignedTypes inline fun UIntArray.runningReduce(     operation: (acc: UInt, UInt) -> UInt ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.runningReduce(     operation: (acc: ULong, ULong) -> ULong ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.runningReduce(     operation: (acc: UByte, UByte) -> UByte ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.runningReduce(     operation: (acc: UShort, UShort) -> UShort ): List<UShort> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.UIntArray,%20kotlin.Function2((kotlin.UInt,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. Note that `acc` value passed to [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.UIntArray,%20kotlin.Function2((kotlin.UInt,%20,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. kotlin ifEmpty ifEmpty ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [ifEmpty](if-empty) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` Returns this array if it's not empty or the result of calling [defaultValue](if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyArray: Array<Any> = emptyArray() val emptyOrNull: Array<Any>? = emptyArray.ifEmpty { null } println(emptyOrNull) // null val emptyOrDefault: Array<Any> = emptyArray.ifEmpty { arrayOf("default") } println(emptyOrDefault.contentToString()) // [default] val nonEmptyArray = arrayOf(1) val sameArray = nonEmptyArray.ifEmpty { arrayOf(2) } println("nonEmptyArray === sameArray is ${nonEmptyArray === sameArray}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <M, R> M.ifEmpty(     defaultValue: () -> R ): R where M : Map<*, *>, M : R ``` Returns this map if it's not empty or the result of calling [defaultValue](if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.M,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the map is empty. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val emptyMap: Map<String, Int> = emptyMap() val emptyOrNull = emptyMap.ifEmpty { null } println(emptyOrNull) // null val emptyOrDefault: Map<String, Any> = emptyMap.ifEmpty { mapOf("s" to "a") } println(emptyOrDefault) // {s=a} val nonEmptyMap = mapOf("x" to 1) val sameMap = nonEmptyMap.ifEmpty { null } println("nonEmptyMap === sameMap is ${nonEmptyMap === sameMap}") // true //sampleEnd } ``` kotlin filterIsInstanceTo filterIsInstanceTo ================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterIsInstanceTo](filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <reified R, C : MutableCollection<in R>> Array<*>.filterIsInstanceTo(     destination: C ): C ``` ``` fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` Appends all elements that are instances of specified type parameter R to the given [destination](filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.Array((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart open class Animal(val name: String) { override fun toString(): String { return name } } class Dog(name: String): Animal(name) class Cat(name: String): Animal(name) val animals: List<Animal> = listOf(Cat("Scratchy"), Dog("Poochie")) val cats = mutableListOf<Cat>() println(cats) // [] animals.filterIsInstanceTo<Cat, MutableList<Cat>>(cats) println(cats) // [Scratchy] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0) ``` fun <C : MutableCollection<in R>, R> Array<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` Appends all elements that are instances of specified class to the given [destination](filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.Array((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart open class Animal(val name: String) { override fun toString(): String { return name } } class Dog(name: String): Animal(name) class Cat(name: String): Animal(name) val animals: List<Animal> = listOf(Cat("Scratchy"), Dog("Poochie")) val cats = mutableListOf<Cat>() println(cats) // [] animals.filterIsInstanceTo(cats, Cat::class.java) println(cats) // [Scratchy] //sampleEnd } ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Array<out T>.contains(element: T): Boolean ``` ``` operator fun ByteArray.contains(element: Byte): Boolean ``` ``` operator fun ShortArray.contains(element: Short): Boolean ``` ``` operator fun IntArray.contains(element: Int): Boolean ``` ``` operator fun LongArray.contains(element: Long): Boolean ``` ``` @DeprecatedSinceKotlin("1.4", "1.6", "1.7") operator fun FloatArray.contains(     element: Float ): Boolean ``` **Deprecated:** The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list. ``` @DeprecatedSinceKotlin("1.4", "1.6", "1.7") operator fun DoubleArray.contains(     element: Double ): Boolean ``` **Deprecated:** The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list. ``` operator fun BooleanArray.contains(element: Boolean): Boolean ``` ``` operator fun CharArray.contains(element: Char): Boolean ``` Returns `true` if [element](contains#kotlin.collections%24contains(kotlin.Array((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` Returns `true` if [element](contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.contains(key: K): Boolean ``` Checks if the map contains the given key. This method allows to use the `x in map` syntax for checking whether an object is contained in the map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map: Map<String, Int> = mapOf("x" to 1) println("map.contains(\"x\") is ${map.contains("x")}") // true println("\"x\" in map is ${"x" in map}") // true println("map.contains(\"y\") is ${map.contains("y")}") // false println("\"y\" in map is ${"y" in map}") // false //sampleEnd } ``` kotlin mapValuesTo mapValuesTo =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapValuesTo](map-values-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` Populates the given [destination](map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/destination) map with entries having the keys of this map and the values obtained by applying the [transform](map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/transform) function to each entry in this [Map](-map/index#kotlin.collections.Map).
programming_docs
kotlin mapNotNull mapNotNull ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapNotNull](map-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any> Array<out T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-not-null#kotlin.collections%24mapNotNull(kotlin.Array((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings: List<String> = listOf("12a", "45", "", "3") val ints: List<Int> = strings.mapNotNull { it.toIntOrNull() } println(ints) // [45, 3] println(ints.sum()) // 48 //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings: List<String> = listOf("12a", "45", "", "3") val ints: List<Int> = strings.mapNotNull { it.toIntOrNull() } println(ints) // [45, 3] println(ints.sum()) // 48 //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R : Any> Map<out K, V>.mapNotNull(     transform: (Entry<K, V>) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Map((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.collections.mapNotNull.R?)))/transform) function to each entry in the original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mapOf("Alice" to 20, "Tom" to 13, "Bob" to 18) val adults = map.mapNotNull { (name, age) -> name.takeIf { age >= 18 } } println(adults) // [Alice, Bob] //sampleEnd } ``` kotlin associateByTo associateByTo ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [associateByTo](associate-by-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, M : MutableMap<in K, in T>> Array<out T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, in Byte>> ByteArray.associateByTo(     destination: M,     keySelector: (Byte) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, in Short>> ShortArray.associateByTo(     destination: M,     keySelector: (Short) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, in Int>> IntArray.associateByTo(     destination: M,     keySelector: (Int) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, in Long>> LongArray.associateByTo(     destination: M,     keySelector: (Long) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, in Float>> FloatArray.associateByTo(     destination: M,     keySelector: (Float) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, in Double>> DoubleArray.associateByTo(     destination: M,     keySelector: (Double) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, in Boolean>> BooleanArray.associateByTo(     destination: M,     keySelector: (Boolean) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, in Char>> CharArray.associateByTo(     destination: M,     keySelector: (Char) -> K ): M ``` Populates and returns the [destination](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. If any two elements would have the same key returned by [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) the last one gets added to the map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val charCodes = intArrayOf(72, 69, 76, 76, 79) val byChar = mutableMapOf<Char, Int>() println("byChar.isEmpty() is ${byChar.isEmpty()}") // true charCodes.associateByTo(byChar) { Char(it) } println("byChar.isNotEmpty() is ${byChar.isNotEmpty()}") // true // L=76 only occurs once because only the last pair with the same key gets added println(byChar) // {H=72, E=69, L=76, O=79} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, in V>> Array<out T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> ByteArray.associateByTo(     destination: M,     keySelector: (Byte) -> K,     valueTransform: (Byte) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> ShortArray.associateByTo(     destination: M,     keySelector: (Short) -> K,     valueTransform: (Short) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> IntArray.associateByTo(     destination: M,     keySelector: (Int) -> K,     valueTransform: (Int) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> LongArray.associateByTo(     destination: M,     keySelector: (Long) -> K,     valueTransform: (Long) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> FloatArray.associateByTo(     destination: M,     keySelector: (Float) -> K,     valueTransform: (Float) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> DoubleArray.associateByTo(     destination: M,     keySelector: (Double) -> K,     valueTransform: (Double) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> BooleanArray.associateByTo(     destination: M,     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> CharArray.associateByTo(     destination: M,     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): M ``` Populates and returns the [destination](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. If any two elements would have the same key returned by [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) the last one gets added to the map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val charCodes = intArrayOf(65, 65, 66, 67, 68, 69) val byUpperCase = mutableMapOf<Char, Char>() charCodes.associateByTo(byUpperCase, { Char(it) }, { Char(it + 32) }) // A=a only occurs once because only the last pair with the same key gets added println(byUpperCase) // {A=a, B=b, C=c, D=d, E=e} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. If any two elements would have the same key returned by [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) the last one gets added to the map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = mutableMapOf<String, Person>() println("byLastName.isEmpty() is ${byLastName.isEmpty()}") // true scientists.associateByTo(byLastName) { it.lastName } println("byLastName.isNotEmpty() is ${byLastName.isNotEmpty()}") // true // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace Hopper, Bernoulli=Johann Bernoulli} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` Populates and returns the [destination](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. If any two elements would have the same key returned by [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) the last one gets added to the map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = mutableMapOf<String, String>() println("byLastName.isEmpty() is ${byLastName.isEmpty()}") // true scientists.associateByTo(byLastName, { it.lastName }, { it.firstName} ) println("byLastName.isNotEmpty() is ${byLastName.isNotEmpty()}") // true // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace, Bernoulli=Johann} //sampleEnd } ``` kotlin linkedStringSetOf linkedStringSetOf ================= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [linkedStringSetOf](linked-string-set-of) **Platform and version requirements:** JS (1.1) ``` fun linkedStringSetOf(     vararg elements: String ): LinkedHashSet<String> ``` Creates a new instance of the specialized implementation of [LinkedHashSet](-linked-hash-set/index#kotlin.collections.LinkedHashSet) with the specified String elements, which elements the keys as properties of JS object without hashing them. kotlin copyOf copyOf ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [copyOf](copy-of) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` fun <T> Array<T>.copyOf(): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> Array<out T>.copyOf(): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun ByteArray.copyOf(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun ShortArray.copyOf(): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun IntArray.copyOf(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun LongArray.copyOf(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun FloatArray.copyOf(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun DoubleArray.copyOf(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun BooleanArray.copyOf(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun CharArray.copyOf(): CharArray ``` Returns new array which is a copy of the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf("apples", "oranges", "limes") val arrayCopy = array.copyOf() println(arrayCopy.contentToString()) // [apples, oranges, limes] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.copyOf(newSize: Int): ByteArray ``` ``` fun ShortArray.copyOf(newSize: Int): ShortArray ``` ``` fun IntArray.copyOf(newSize: Int): IntArray ``` ``` fun LongArray.copyOf(newSize: Int): LongArray ``` ``` fun FloatArray.copyOf(newSize: Int): FloatArray ``` ``` fun DoubleArray.copyOf(newSize: Int): DoubleArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.ByteArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with zero values if necessary. * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.ByteArray,%20kotlin.Int)/newSize) is less than the size of the original array, the copy array is truncated to the [newSize](copy-of#kotlin.collections%24copyOf(kotlin.ByteArray,%20kotlin.Int)/newSize). * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.ByteArray,%20kotlin.Int)/newSize) is greater than the size of the original array, the extra elements in the copy array are filled with zero values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = intArrayOf(1, 2, 3) val arrayCopyPadded = array.copyOf(5) println(arrayCopyPadded.contentToString()) // [1, 2, 3, 0, 0] val arrayCopyTruncated = array.copyOf(2) println(arrayCopyTruncated.contentToString()) // [1, 2] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun BooleanArray.copyOf(newSize: Int): BooleanArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.BooleanArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with `false` values if necessary. * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.BooleanArray,%20kotlin.Int)/newSize) is less than the size of the original array, the copy array is truncated to the [newSize](copy-of#kotlin.collections%24copyOf(kotlin.BooleanArray,%20kotlin.Int)/newSize). * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.BooleanArray,%20kotlin.Int)/newSize) is greater than the size of the original array, the extra elements in the copy array are filled with `false` values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = intArrayOf(1, 2, 3) val arrayCopyPadded = array.copyOf(5) println(arrayCopyPadded.contentToString()) // [1, 2, 3, 0, 0] val arrayCopyTruncated = array.copyOf(2) println(arrayCopyTruncated.contentToString()) // [1, 2] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharArray.copyOf(newSize: Int): CharArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.CharArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with null char (`\u0000`) values if necessary. * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.CharArray,%20kotlin.Int)/newSize) is less than the size of the original array, the copy array is truncated to the [newSize](copy-of#kotlin.collections%24copyOf(kotlin.CharArray,%20kotlin.Int)/newSize). * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.CharArray,%20kotlin.Int)/newSize) is greater than the size of the original array, the extra elements in the copy array are filled with null char (`\u0000`) values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = intArrayOf(1, 2, 3) val arrayCopyPadded = array.copyOf(5) println(arrayCopyPadded.contentToString()) // [1, 2, 3, 0, 0] val arrayCopyTruncated = array.copyOf(2) println(arrayCopyTruncated.contentToString()) // [1, 2] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` fun <T> Array<T>.copyOf(newSize: Int): Array<T?> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> Array<out T>.copyOf(newSize: Int): Array<T?> ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.Array((kotlin.collections.copyOf.T)),%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with `null` values if necessary. * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.Array((kotlin.collections.copyOf.T)),%20kotlin.Int)/newSize) is less than the size of the original array, the copy array is truncated to the [newSize](copy-of#kotlin.collections%24copyOf(kotlin.Array((kotlin.collections.copyOf.T)),%20kotlin.Int)/newSize). * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.Array((kotlin.collections.copyOf.T)),%20kotlin.Int)/newSize) is greater than the size of the original array, the extra elements in the copy array are filled with `null` values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf("apples", "oranges", "limes") val arrayCopyPadded = array.copyOf(5) println(arrayCopyPadded.contentToString()) // [apples, oranges, limes, null, null] val arrayCopyTruncated = array.copyOf(2) println(arrayCopyTruncated.contentToString()) // [apples, oranges] //sampleEnd } ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.copyOf(): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.copyOf(): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.copyOf(): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.copyOf(): UShortArray ``` Returns new array which is a copy of the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf("apples", "oranges", "limes") val arrayCopy = array.copyOf() println(arrayCopy.contentToString()) // [apples, oranges, limes] //sampleEnd } ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.copyOf(     newSize: Int ): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.copyOf(     newSize: Int ): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.copyOf(     newSize: Int ): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.copyOf(     newSize: Int ): UShortArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.UIntArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with zero values if necessary. * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.UIntArray,%20kotlin.Int)/newSize) is less than the size of the original array, the copy array is truncated to the [newSize](copy-of#kotlin.collections%24copyOf(kotlin.UIntArray,%20kotlin.Int)/newSize). * If [newSize](copy-of#kotlin.collections%24copyOf(kotlin.UIntArray,%20kotlin.Int)/newSize) is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
programming_docs
kotlin fill fill ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <fill> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<T>.fill(     element: T,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun ByteArray.fill(     element: Byte,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun ShortArray.fill(     element: Short,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun IntArray.fill(     element: Int,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun LongArray.fill(     element: Long,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun FloatArray.fill(     element: Float,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun DoubleArray.fill(     element: Double,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun BooleanArray.fill(     element: Boolean,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun CharArray.fill(     element: Char,     fromIndex: Int = 0,     toIndex: Int = size) ``` Fills this array or its subrange with the specified [element](fill#kotlin.collections%24fill(kotlin.Array((kotlin.collections.fill.T)),%20kotlin.collections.fill.T,%20kotlin.Int,%20kotlin.Int)/element) value. Parameters ---------- `fromIndex` - the start of the range (inclusive) to fill, 0 by default. `toIndex` - the end of the range (exclusive) to fill, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](fill#kotlin.collections%24fill(kotlin.Array((kotlin.collections.fill.T)),%20kotlin.collections.fill.T,%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](fill#kotlin.collections%24fill(kotlin.Array((kotlin.collections.fill.T)),%20kotlin.collections.fill.T,%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](fill#kotlin.collections%24fill(kotlin.Array((kotlin.collections.fill.T)),%20kotlin.collections.fill.T,%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](fill#kotlin.collections%24fill(kotlin.Array((kotlin.collections.fill.T)),%20kotlin.collections.fill.T,%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.fill(     element: UInt,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` @ExperimentalUnsignedTypes fun ULongArray.fill(     element: ULong,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` @ExperimentalUnsignedTypes fun UByteArray.fill(     element: UByte,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` @ExperimentalUnsignedTypes fun UShortArray.fill(     element: UShort,     fromIndex: Int = 0,     toIndex: Int = size) ``` Fills this array or its subrange with the specified [element](fill#kotlin.collections%24fill(kotlin.UIntArray,%20kotlin.UInt,%20kotlin.Int,%20kotlin.Int)/element) value. Parameters ---------- `fromIndex` - the start of the range (inclusive) to fill, 0 by default. `toIndex` - the end of the range (exclusive) to fill, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](fill#kotlin.collections%24fill(kotlin.UIntArray,%20kotlin.UInt,%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](fill#kotlin.collections%24fill(kotlin.UIntArray,%20kotlin.UInt,%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](fill#kotlin.collections%24fill(kotlin.UIntArray,%20kotlin.UInt,%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](fill#kotlin.collections%24fill(kotlin.UIntArray,%20kotlin.UInt,%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.2), JS (1.2) ``` fun <T> MutableList<T>.fill(value: T) ``` Fills the list with the provided [value](fill#kotlin.collections%24fill(kotlin.collections.MutableList((kotlin.collections.fill.T)),%20kotlin.collections.fill.T)/value). Each element in the list gets replaced with the [value](fill#kotlin.collections%24fill(kotlin.collections.MutableList((kotlin.collections.fill.T)),%20kotlin.collections.fill.T)/value). kotlin any any === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <any> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.any(): Boolean ``` ``` fun ByteArray.any(): Boolean ``` ``` fun ShortArray.any(): Boolean ``` ``` fun IntArray.any(): Boolean ``` ``` fun LongArray.any(): Boolean ``` ``` fun FloatArray.any(): Boolean ``` ``` fun DoubleArray.any(): Boolean ``` ``` fun BooleanArray.any(): Boolean ``` ``` fun CharArray.any(): Boolean ``` ``` @ExperimentalUnsignedTypes fun UIntArray.any(): Boolean ``` ``` @ExperimentalUnsignedTypes fun ULongArray.any(): Boolean ``` ``` @ExperimentalUnsignedTypes fun UByteArray.any(): Boolean ``` ``` @ExperimentalUnsignedTypes fun UShortArray.any(): Boolean ``` Returns `true` if array has at least one element. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.any() is ${emptyList.any()}") // false val nonEmptyList = listOf(1, 2, 3) println("nonEmptyList.any() is ${nonEmptyList.any()}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.any(     predicate: (T) -> Boolean ): Boolean ``` ``` inline fun ByteArray.any(     predicate: (Byte) -> Boolean ): Boolean ``` ``` inline fun ShortArray.any(     predicate: (Short) -> Boolean ): Boolean ``` ``` inline fun IntArray.any(predicate: (Int) -> Boolean): Boolean ``` ``` inline fun LongArray.any(     predicate: (Long) -> Boolean ): Boolean ``` ``` inline fun FloatArray.any(     predicate: (Float) -> Boolean ): Boolean ``` ``` inline fun DoubleArray.any(     predicate: (Double) -> Boolean ): Boolean ``` ``` inline fun BooleanArray.any(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.any(     predicate: (Char) -> Boolean ): Boolean ``` ``` inline fun <T> Iterable<T>.any(     predicate: (T) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.any(     predicate: (UInt) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.any(     predicate: (ULong) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.any(     predicate: (UByte) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.any(     predicate: (UShort) -> Boolean ): Boolean ``` Returns `true` if at least one element matches the given [predicate](any#kotlin.collections%24any(kotlin.Array((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.any { isEven(it) } is ${zeroToTen.any { isEven(it) }}") // true println("zeroToTen.any(isEven) is ${zeroToTen.any(isEven)}") // true val odds = zeroToTen.map { it * 2 + 1 } println("odds.any { isEven(it) } is ${odds.any { isEven(it) }}") // false val emptyList = emptyList<Int>() println("emptyList.any { true } is ${emptyList.any { true }}") // false //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if collection has at least one element. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.any() is ${emptyList.any()}") // false val nonEmptyList = listOf(1, 2, 3) println("nonEmptyList.any() is ${nonEmptyList.any()}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<out K, V>.any(): Boolean ``` Returns `true` if map has at least one entry. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.any() is ${emptyList.any()}") // false val nonEmptyList = listOf(1, 2, 3) println("nonEmptyList.any() is ${nonEmptyList.any()}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.any(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` Returns `true` if at least one entry matches the given [predicate](any#kotlin.collections%24any(kotlin.collections.Map((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.any { isEven(it) } is ${zeroToTen.any { isEven(it) }}") // true println("zeroToTen.any(isEven) is ${zeroToTen.any(isEven)}") // true val odds = zeroToTen.map { it * 2 + 1 } println("odds.any { isEven(it) } is ${odds.any { isEven(it) }}") // false val emptyList = emptyList<Int>() println("emptyList.any { true } is ${emptyList.any { true }}") // false //sampleEnd } ``` kotlin map map === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <map> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Array<out T>.map(     transform: (T) -> R ): List<R> ``` ``` inline fun <R> ByteArray.map(transform: (Byte) -> R): List<R> ``` ``` inline fun <R> ShortArray.map(     transform: (Short) -> R ): List<R> ``` ``` inline fun <R> IntArray.map(transform: (Int) -> R): List<R> ``` ``` inline fun <R> LongArray.map(transform: (Long) -> R): List<R> ``` ``` inline fun <R> FloatArray.map(     transform: (Float) -> R ): List<R> ``` ``` inline fun <R> DoubleArray.map(     transform: (Double) -> R ): List<R> ``` ``` inline fun <R> BooleanArray.map(     transform: (Boolean) -> R ): List<R> ``` ``` inline fun <R> CharArray.map(transform: (Char) -> R): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.map(     transform: (UInt) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.map(     transform: (ULong) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.map(     transform: (UByte) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.map(     transform: (UShort) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](map#kotlin.collections%24map(kotlin.Array((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3) println(numbers.map { it * it }) // [1, 4, 9] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Iterable<T>.map(     transform: (T) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3) println(numbers.map { it * it }) // [1, 4, 9] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R> Map<out K, V>.map(     transform: (Entry<K, V>) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](map#kotlin.collections%24map(kotlin.collections.Map((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.collections.map.R)))/transform) function to each entry in the original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val peopleToAge = mapOf("Alice" to 20, "Bob" to 21) println(peopleToAge.map { (name, age) -> "$name is $age years old" }) // [Alice is 20 years old, Bob is 21 years old] println(peopleToAge.map { it.value }) // [20, 21] //sampleEnd } ``` kotlin sorted sorted ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <sorted> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> Array<out T>.sorted(): List<T> ``` ``` fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> ``` Returns a list of all elements sorted according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.sorted(): List<Byte> ``` ``` fun ShortArray.sorted(): List<Short> ``` ``` fun IntArray.sorted(): List<Int> ``` ``` fun LongArray.sorted(): List<Long> ``` ``` fun FloatArray.sorted(): List<Float> ``` ``` fun DoubleArray.sorted(): List<Double> ``` ``` fun CharArray.sorted(): List<Char> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sorted(): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sorted(): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sorted(): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sorted(): List<UShort> ``` Returns a list of all elements sorted according to their natural sort order. kotlin toULongArray toULongArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toULongArray](to-u-long-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun Array<out ULong>.toULongArray(): ULongArray ``` Returns an array of ULong containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun LongArray.toULongArray(): ULongArray ``` Returns an array of type [ULongArray](../kotlin/-u-long-array/index), which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun Collection<ULong>.toULongArray(): ULongArray ``` Returns an array of ULong containing all of the elements of this collection. kotlin reduceIndexed reduceIndexed ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reduceIndexed](reduce-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> Array<out T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` ``` inline fun ByteArray.reduceIndexed(     operation: (index: Int, acc: Byte, Byte) -> Byte ): Byte ``` ``` inline fun ShortArray.reduceIndexed(     operation: (index: Int, acc: Short, Short) -> Short ): Short ``` ``` inline fun IntArray.reduceIndexed(     operation: (index: Int, acc: Int, Int) -> Int ): Int ``` ``` inline fun LongArray.reduceIndexed(     operation: (index: Int, acc: Long, Long) -> Long ): Long ``` ``` inline fun FloatArray.reduceIndexed(     operation: (index: Int, acc: Float, Float) -> Float ): Float ``` ``` inline fun DoubleArray.reduceIndexed(     operation: (index: Int, acc: Double, Double) -> Double ): Double ``` ``` inline fun BooleanArray.reduceIndexed(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.reduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): Char ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.reduceIndexed(     operation: (index: Int, acc: UInt, UInt) -> UInt ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.reduceIndexed(     operation: (index: Int, acc: ULong, ULong) -> ULong ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.reduceIndexed(     operation: (index: Int, acc: UByte, UByte) -> UByte ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.reduceIndexed(     operation: (index: Int, acc: UShort, UShort) -> UShort ): UShort ``` Accumulates value starting with the first element and applying [operation](reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.Array((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. Throws an exception if this array is empty. If the array can be empty in an expected way, please use [reduceIndexedOrNull](reduce-indexed-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduce { acc, string -> acc + string }) // abcd println(strings.reduceIndexed { index, acc, string -> acc + string + index }) // ab1c2d3 // emptyList<Int>().reduce { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` Accumulates value starting with the first element and applying [operation](reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. Throws an exception if this collection is empty. If the collection can be empty in an expected way, please use [reduceIndexedOrNull](reduce-indexed-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduce { acc, string -> acc + string }) // abcd println(strings.reduceIndexed { index, acc, string -> acc + string + index }) // ab1c2d3 // emptyList<Int>().reduce { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. kotlin asUIntArray asUIntArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asUIntArray](as-u-int-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun IntArray.asUIntArray(): UIntArray ``` Returns an array of type [UIntArray](../kotlin/-u-int-array/index), which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array. kotlin listOf listOf ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [listOf](list-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> listOf(vararg elements: T): List<T> ``` Returns a new read-only list of given elements. The returned list is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'b', 'c') println(list.size) // 3 println("list.contains('a') is ${list.contains('a')}") // true println(list.indexOf('b')) // 1 println(list[2]) // c //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> listOf(): List<T> ``` Returns an empty read-only list. The returned list is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf<String>() println("list.isEmpty() is ${list.isEmpty()}") // true // another way to create an empty list, // type parameter is inferred from the expected type val other: List<Int> = emptyList() // Empty lists are equal println("list == other is ${list == other}") // true println(list) // [] // list[0] // will fail //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0) ``` fun <T> listOf(element: T): List<T> ``` ##### For JVM Returns an immutable list containing only the specified object [element](list-of#kotlin.collections%24listOf(kotlin.collections.listOf.T)/element). The returned list is serializable. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a') println(list) // [a] println(list.size) // 1 //sampleEnd } ``` ##### For JS Returns an immutable list containing only the specified object [element](list-of#kotlin.collections%24listOf(kotlin.collections.listOf.T)/element).
programming_docs
kotlin plusElement plusElement =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [plusElement](plus-element) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` fun <T> Array<T>.plusElement(element: T): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> Array<out T>.plusElement(element: T): Array<T> ``` Returns an array containing all elements of the original array and then the given [element](plus-element#kotlin.collections%24plusElement(kotlin.Array((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` Returns a list containing all elements of the original collection and then the given [element](plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Set<T>.plusElement(element: T): Set<T> ``` Returns a set containing all elements of the original set and then the given [element](plus-element#kotlin.collections%24plusElement(kotlin.collections.Set((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element) if it isn't already in this set. The returned set preserves the element iteration order of the original set. kotlin union union ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <union> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T> Array<out T>.union(other: Iterable<T>): Set<T> ``` ``` infix fun ByteArray.union(other: Iterable<Byte>): Set<Byte> ``` ``` infix fun ShortArray.union(     other: Iterable<Short> ): Set<Short> ``` ``` infix fun IntArray.union(other: Iterable<Int>): Set<Int> ``` ``` infix fun LongArray.union(other: Iterable<Long>): Set<Long> ``` ``` infix fun FloatArray.union(     other: Iterable<Float> ): Set<Float> ``` ``` infix fun DoubleArray.union(     other: Iterable<Double> ): Set<Double> ``` ``` infix fun BooleanArray.union(     other: Iterable<Boolean> ): Set<Boolean> ``` ``` infix fun CharArray.union(other: Iterable<Char>): Set<Char> ``` Returns a set containing all distinct elements from both collections. The returned set preserves the element iteration order of the original array. Those elements of the [other](union#kotlin.collections%24union(kotlin.Array((kotlin.collections.union.T)),%20kotlin.collections.Iterable((kotlin.collections.union.T)))/other) collection that are unique are iterated in the end in the order of the [other](union#kotlin.collections%24union(kotlin.Array((kotlin.collections.union.T)),%20kotlin.collections.Iterable((kotlin.collections.union.T)))/other) collection. To get a set containing all elements that are contained in both collections use <intersect>. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` Returns a set containing all distinct elements from both collections. The returned set preserves the element iteration order of the original collection. Those elements of the [other](union#kotlin.collections%24union(kotlin.collections.Iterable((kotlin.collections.union.T)),%20kotlin.collections.Iterable((kotlin.collections.union.T)))/other) collection that are unique are iterated in the end in the order of the [other](union#kotlin.collections%24union(kotlin.collections.Iterable((kotlin.collections.union.T)),%20kotlin.collections.Iterable((kotlin.collections.union.T)))/other) collection. To get a set containing all elements that are contained in both collections use <intersect>. kotlin removeFirst removeFirst =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [removeFirst](remove-first) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> MutableList<T>.removeFirst(): T ``` Removes the first element from this mutable list and returns that removed element, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. kotlin sumByDouble sumByDouble =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sumByDouble](sum-by-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") inline fun <T> Array<out T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun ByteArray.sumByDouble(     selector: (Byte) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun ShortArray.sumByDouble(     selector: (Short) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun IntArray.sumByDouble(     selector: (Int) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun LongArray.sumByDouble(     selector: (Long) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun FloatArray.sumByDouble(     selector: (Float) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun DoubleArray.sumByDouble(     selector: (Double) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun BooleanArray.sumByDouble(     selector: (Boolean) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun CharArray.sumByDouble(     selector: (Char) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") @ExperimentalUnsignedTypes inline fun UIntArray.sumByDouble(     selector: (UInt) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") @ExperimentalUnsignedTypes inline fun ULongArray.sumByDouble(     selector: (ULong) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") @ExperimentalUnsignedTypes inline fun UByteArray.sumByDouble(     selector: (UByte) -> Double ): Double ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") @ExperimentalUnsignedTypes inline fun UShortArray.sumByDouble(     selector: (UShort) -> Double ): Double ``` **Deprecated:** Use sumOf instead. Returns the sum of all values produced by [selector](sum-by-double#kotlin.collections%24sumByDouble(kotlin.Array((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") inline fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Deprecated:** Use sumOf instead. Returns the sum of all values produced by [selector](sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. kotlin toList toList ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toList](to-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.toList(): List<T> ``` ``` fun ByteArray.toList(): List<Byte> ``` ``` fun ShortArray.toList(): List<Short> ``` ``` fun IntArray.toList(): List<Int> ``` ``` fun LongArray.toList(): List<Long> ``` ``` fun FloatArray.toList(): List<Float> ``` ``` fun DoubleArray.toList(): List<Double> ``` ``` fun BooleanArray.toList(): List<Boolean> ``` ``` fun CharArray.toList(): List<Char> ``` ``` fun <T> Iterable<T>.toList(): List<T> ``` Returns a [List](-list/index#kotlin.collections.List) containing all elements. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> ``` Returns a [List](-list/index#kotlin.collections.List) containing all key-value pairs. kotlin toMutableList toMutableList ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toMutableList](to-mutable-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.toMutableList(): MutableList<T> ``` ``` fun ByteArray.toMutableList(): MutableList<Byte> ``` ``` fun ShortArray.toMutableList(): MutableList<Short> ``` ``` fun IntArray.toMutableList(): MutableList<Int> ``` ``` fun LongArray.toMutableList(): MutableList<Long> ``` ``` fun FloatArray.toMutableList(): MutableList<Float> ``` ``` fun DoubleArray.toMutableList(): MutableList<Double> ``` ``` fun BooleanArray.toMutableList(): MutableList<Boolean> ``` ``` fun CharArray.toMutableList(): MutableList<Char> ``` Returns a new [MutableList](-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.toMutableList(): MutableList<T> ``` ``` fun <T> Collection<T>.toMutableList(): MutableList<T> ``` Returns a new [MutableList](-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this collection. kotlin forEach forEach ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [forEach](for-each) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.forEach(action: (T) -> Unit) ``` ``` inline fun ByteArray.forEach(action: (Byte) -> Unit) ``` ``` inline fun ShortArray.forEach(action: (Short) -> Unit) ``` ``` inline fun IntArray.forEach(action: (Int) -> Unit) ``` ``` inline fun LongArray.forEach(action: (Long) -> Unit) ``` ``` inline fun FloatArray.forEach(action: (Float) -> Unit) ``` ``` inline fun DoubleArray.forEach(action: (Double) -> Unit) ``` ``` inline fun BooleanArray.forEach(action: (Boolean) -> Unit) ``` ``` inline fun CharArray.forEach(action: (Char) -> Unit) ``` ``` inline fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.forEach(     action: (UInt) -> Unit) ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.forEach(     action: (ULong) -> Unit) ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.forEach(     action: (UByte) -> Unit) ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.forEach(     action: (UShort) -> Unit) ``` Performs the given [action](for-each#kotlin.collections%24forEach(kotlin.Array((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.forEach(     action: (Entry<K, V>) -> Unit) ``` Performs the given [action](for-each#kotlin.collections%24forEach(kotlin.collections.Map((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Unit)))/action) on each entry. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` Performs the given [operation](for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](-iterator/index#kotlin.collections.Iterator). ``` import java.util.* fun main(args: Array<String>) { //sampleStart val iterator = (1..3).iterator() // skip an element if (iterator.hasNext()) { iterator.next() } // do something with the rest of elements iterator.forEach { println("The element is $it") } //sampleEnd } ``` kotlin drop drop ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <drop> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.drop(n: Int): List<T> ``` ``` fun ByteArray.drop(n: Int): List<Byte> ``` ``` fun ShortArray.drop(n: Int): List<Short> ``` ``` fun IntArray.drop(n: Int): List<Int> ``` ``` fun LongArray.drop(n: Int): List<Long> ``` ``` fun FloatArray.drop(n: Int): List<Float> ``` ``` fun DoubleArray.drop(n: Int): List<Double> ``` ``` fun BooleanArray.drop(n: Int): List<Boolean> ``` ``` fun CharArray.drop(n: Int): List<Char> ``` ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.drop(     n: Int ): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.drop(     n: Int ): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.drop(     n: Int ): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.drop(     n: Int ): List<UShort> ``` Returns a list containing all elements except first [n](drop#kotlin.collections%24drop(kotlin.Array((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.drop(23)) // [x, y, z] println(chars.dropLast(23)) // [a, b, c] println(chars.dropWhile { it < 'x' }) // [x, y, z] println(chars.dropLastWhile { it > 'c' }) // [a, b, c] //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](drop#kotlin.collections%24drop(kotlin.Array((kotlin.collections.drop.T)),%20kotlin.Int)/n) is negative. kotlin take take ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <take> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.take(n: Int): List<T> ``` ``` fun ByteArray.take(n: Int): List<Byte> ``` ``` fun ShortArray.take(n: Int): List<Short> ``` ``` fun IntArray.take(n: Int): List<Int> ``` ``` fun LongArray.take(n: Int): List<Long> ``` ``` fun FloatArray.take(n: Int): List<Float> ``` ``` fun DoubleArray.take(n: Int): List<Double> ``` ``` fun BooleanArray.take(n: Int): List<Boolean> ``` ``` fun CharArray.take(n: Int): List<Char> ``` ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.take(     n: Int ): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.take(     n: Int ): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.take(     n: Int ): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.take(     n: Int ): List<UShort> ``` Returns a list containing first [n](take#kotlin.collections%24take(kotlin.Array((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.take(3)) // [a, b, c] println(chars.takeWhile { it < 'f' }) // [a, b, c, d, e] println(chars.takeLast(2)) // [y, z] println(chars.takeLastWhile { it > 'w' }) // [x, y, z] //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](take#kotlin.collections%24take(kotlin.Array((kotlin.collections.take.T)),%20kotlin.Int)/n) is negative. kotlin setOfNotNull setOfNotNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [setOfNotNull](set-of-not-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Any> setOfNotNull(element: T?): Set<T> ``` Returns a new read-only set either with single given element, if it is not null, or empty set if the element is null. The returned set is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val empty = setOfNotNull<Any>(null) println(empty) // [] val singleton = setOfNotNull(42) println(singleton) // [42] val set = setOfNotNull(1, null, 2, null, 3) println(set) // [1, 2, 3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Any> setOfNotNull(vararg elements: T?): Set<T> ``` Returns a new read-only set only with those given elements, that are not null. Elements of the set are iterated in the order they were specified. The returned set is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val empty = setOfNotNull<Any>(null) println(empty) // [] val singleton = setOfNotNull(42) println(singleton) // [42] val set = setOfNotNull(1, null, 2, null, 3) println(set) // [1, 2, 3] //sampleEnd } ``` kotlin foldTo foldTo ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [foldTo](fold-to) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(     destination: M,     initialValueSelector: (key: K, element: T) -> R,     operation: (key: K, accumulator: R, element: T) -> R ): M ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map. An initial value of accumulator is provided by [initialValueSelector](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/initialValueSelector) function. ``` fun main(args: Array<String>) { //sampleStart val fruits = listOf("cherry", "blueberry", "citrus", "apple", "apricot", "banana", "coconut") val evenFruits = fruits.groupingBy { it.first() } .foldTo(mutableMapOf(), { key, _: String -> key to mutableListOf<String>() }, { _, accumulator, element -> if (element.length % 2 == 0) accumulator.second.add(element) accumulator }) val sorted = evenFruits.values.sortedBy { it.first } println(sorted) // [(a, []), (b, [banana]), (c, [cherry, citrus])] evenFruits.clear() // evenFruits is a mutable map //sampleEnd } ``` Parameters ---------- `initialValueSelector` - a function that provides an initial value of accumulator for each group. It's invoked with parameters: * `key`: the key of the group; * `element`: the first element being encountered in that group. If the [destination](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map already has a value corresponding to some key, that value is used as an initial value of the accumulator for that group and the [initialValueSelector](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/initialValueSelector) function is not called for that group. `operation` - a function that is invoked on each element with the following parameters: **Return** the [destination](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map associating the key of each group with the result of accumulating the group elements. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(     destination: M,     initialValue: R,     operation: (accumulator: R, element: T) -> R ): M ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map. An initial value of accumulator is the same [initialValue](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/initialValue) for each group. If the [destination](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map already has a value corresponding to the key of some group, that value is used as an initial value of the accumulator for that group. ``` fun main(args: Array<String>) { //sampleStart val fruits = listOf("apple", "apricot", "banana", "blueberry", "cherry", "coconut") // collect only even length Strings val evenFruits = fruits.groupingBy { it.first() } .foldTo(mutableMapOf(), emptyList<String>()) { acc, e -> if (e.length % 2 == 0) acc + e else acc } println(evenFruits) // {a=[], b=[banana], c=[cherry]} evenFruits.clear() // evenFruits is a mutable map //sampleEnd } ``` Parameters ---------- `operation` - a function that is invoked on each element with the following parameters: **Return** the [destination](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map associating the key of each group with the result of accumulating the group elements.
programming_docs
kotlin last last ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.last(): T ``` ``` fun ByteArray.last(): Byte ``` ``` fun ShortArray.last(): Short ``` ``` fun IntArray.last(): Int ``` ``` fun LongArray.last(): Long ``` ``` fun FloatArray.last(): Float ``` ``` fun DoubleArray.last(): Double ``` ``` fun BooleanArray.last(): Boolean ``` ``` fun CharArray.last(): Char ``` ``` @ExperimentalUnsignedTypes fun UIntArray.last(): UInt ``` ``` @ExperimentalUnsignedTypes fun ULongArray.last(): ULong ``` ``` @ExperimentalUnsignedTypes fun UByteArray.last(): UByte ``` ``` @ExperimentalUnsignedTypes fun UShortArray.last(): UShort ``` Returns the last element. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.last(     predicate: (T) -> Boolean ): T ``` ``` inline fun ByteArray.last(predicate: (Byte) -> Boolean): Byte ``` ``` inline fun ShortArray.last(     predicate: (Short) -> Boolean ): Short ``` ``` inline fun IntArray.last(predicate: (Int) -> Boolean): Int ``` ``` inline fun LongArray.last(predicate: (Long) -> Boolean): Long ``` ``` inline fun FloatArray.last(     predicate: (Float) -> Boolean ): Float ``` ``` inline fun DoubleArray.last(     predicate: (Double) -> Boolean ): Double ``` ``` inline fun BooleanArray.last(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.last(predicate: (Char) -> Boolean): Char ``` ``` inline fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` ``` inline fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.last(     predicate: (UInt) -> Boolean ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.last(     predicate: (ULong) -> Boolean ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.last(     predicate: (UByte) -> Boolean ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.last(     predicate: (UShort) -> Boolean ): UShort ``` Returns the last element matching the given [predicate](last#kotlin.collections%24last(kotlin.Array((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if no such element is found. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.last(): T ``` Returns the last element. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.last(): T ``` Returns the last element. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the list is empty. kotlin maxOfWithOrNull maxOfWithOrNull =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxOfWithOrNull](max-of-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Array<out T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` ``` inline fun <R> ByteArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Byte) -> R ): R? ``` ``` inline fun <R> ShortArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Short) -> R ): R? ``` ``` inline fun <R> IntArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Int) -> R ): R? ``` ``` inline fun <R> LongArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Long) -> R ): R? ``` ``` inline fun <R> FloatArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Float) -> R ): R? ``` ``` inline fun <R> DoubleArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Double) -> R ): R? ``` ``` inline fun <R> BooleanArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R? ``` ``` inline fun <R> CharArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UInt) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UByte) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UShort) -> R ): R? ``` Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.Array((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.Array((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R> Map<out K, V>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. kotlin distinctBy distinctBy ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [distinctBy](distinct-by) **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> ``` Returns a list containing only elements from the given array having distinct keys returned by the given [selector](distinct-by#kotlin.collections%24distinctBy(kotlin.Array((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. Among elements of the given array with equal keys, only the first one will be present in the resulting list. The elements in the resulting list are in the same order as they were in the source array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'A', 'b', 'B', 'A', 'a') println(list.distinct()) // [a, A, b, B] println(list.distinctBy { it.uppercaseChar() }) // [a, b] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` 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](distinct-by#kotlin.collections%24distinctBy(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.distinctBy.K)))/selector) function. The elements in the resulting list are in the same order as they were in the source array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'A', 'b', 'B', 'A', 'a') println(list.distinct()) // [a, A, b, B] println(list.distinctBy { it.uppercaseChar() }) // [a, b] //sampleEnd } ``` **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](distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. Among elements of the given collection with equal keys, only the first one will be present in the resulting list. The elements in the resulting list are in the same order as they were in the source collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'A', 'b', 'B', 'A', 'a') println(list.distinct()) // [a, A, b, B] println(list.distinctBy { it.uppercaseChar() }) // [a, b] //sampleEnd } ``` kotlin Package kotlin.collections Package kotlin.collections ========================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) Collection types, such as [Iterable](-iterable/index#kotlin.collections.Iterable), [Collection](-collection/index#kotlin.collections.Collection), [List](-list/index#kotlin.collections.List), [Set](-set/index#kotlin.collections.Set), [Map](-map/index#kotlin.collections.Map) and related top-level and extension functions. Types ----- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractCollection](-abstract-collection/index) Provides a skeletal implementation of the read-only [Collection](-collection/index#kotlin.collections.Collection) interface. ``` abstract class AbstractCollection<out E> : Collection<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AbstractIterator](-abstract-iterator/index) A base class to simplify implementing iterators so that implementations only have to implement [computeNext](-abstract-iterator/compute-next) to implement the iterator, calling [done](-abstract-iterator/done) when the iteration is complete. ``` abstract class AbstractIterator<T> : Iterator<T> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractList](-abstract-list/index) Provides a skeletal implementation of the read-only [List](-list/index#kotlin.collections.List) interface. ``` abstract class AbstractList<out E> :      AbstractCollection<E>,     List<E> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractMap](-abstract-map/index) Provides a skeletal implementation of the read-only [Map](-map/index#kotlin.collections.Map) interface. ``` abstract class AbstractMap<K, out V> : Map<K, V> ``` #### [AbstractMutableCollection](-abstract-mutable-collection/index) Provides a skeletal implementation of the [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) interface. **Platform and version requirements:** ``` abstract class AbstractMutableCollection<E> :      MutableCollection<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableCollection<E> :      MutableCollection<E>,     AbstractCollection<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableCollection<E> :      AbstractCollection<E>,     MutableCollection<E> ``` #### [AbstractMutableList](-abstract-mutable-list/index) Provides a skeletal implementation of the [MutableList](-mutable-list/index#kotlin.collections.MutableList) interface. **Platform and version requirements:** ``` abstract class AbstractMutableList<E> : MutableList<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableList<E> :      MutableList<E>,     AbstractList<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableList<E> :      AbstractMutableCollection<E>,     MutableList<E> ``` #### [AbstractMutableMap](-abstract-mutable-map/index) Provides a skeletal implementation of the [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) interface. **Platform and version requirements:** ``` abstract class AbstractMutableMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableMap<K, V> :      MutableMap<K, V>,     AbstractMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableMap<K, V> :      AbstractMap<K, V>,     MutableMap<K, V> ``` #### [AbstractMutableSet](-abstract-mutable-set/index) Provides a skeletal implementation of the [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) interface. **Platform and version requirements:** ``` abstract class AbstractMutableSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableSet<E> :      MutableSet<E>,     AbstractSet<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableSet<E> :      AbstractMutableCollection<E>,     MutableSet<E> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractSet](-abstract-set/index) Provides a skeletal implementation of the read-only [Set](-set/index#kotlin.collections.Set) interface. ``` abstract class AbstractSet<out E> :      AbstractCollection<E>,     Set<E> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [ArrayDeque](-array-deque/index) Resizable-array implementation of the deque data structure. ``` class ArrayDeque<E> : AbstractMutableList<E> ``` #### [ArrayList](-array-list/index) Provides a [MutableList](-mutable-list/index#kotlin.collections.MutableList) implementation, which uses a resizable array as its backing storage. **Platform and version requirements:** ``` class ArrayList<E> : MutableList<E>, RandomAccess ``` **Platform and version requirements:** JVM (1.1) ``` typealias ArrayList<E> = ArrayList<E> ``` **Platform and version requirements:** JS (1.1) ``` open class ArrayList<E> :      AbstractMutableList<E>,     MutableList<E>,     RandomAccess ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [BooleanIterator](-boolean-iterator/index) An iterator over a sequence of values of type `Boolean`. ``` abstract class BooleanIterator : Iterator<Boolean> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ByteIterator](-byte-iterator/index) An iterator over a sequence of values of type `Byte`. ``` abstract class ByteIterator : Iterator<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharIterator](-char-iterator/index) An iterator over a sequence of values of type `Char`. ``` abstract class CharIterator : Iterator<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Collection](-collection/index) A generic collection of elements. Methods in this interface support only read-only access to the collection; read/write access is supported through the [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) interface. ``` interface Collection<out E> : Iterable<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [DoubleIterator](-double-iterator/index) An iterator over a sequence of values of type `Double`. ``` abstract class DoubleIterator : Iterator<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FloatIterator](-float-iterator/index) An iterator over a sequence of values of type `Float`. ``` abstract class FloatIterator : Iterator<Float> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [Grouping](-grouping/index) Represents a source of elements with a [keyOf](-grouping/key-of) function, which can be applied to each element to get its key. ``` interface Grouping<T, out K> ``` #### [HashMap](-hash-map/index) Hash table based implementation of the [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) interface. **Platform and version requirements:** ``` class HashMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` typealias HashMap<K, V> = HashMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` open class HashMap<K, V> :      AbstractMutableMap<K, V>,     MutableMap<K, V> ``` #### [HashSet](-hash-set/index) The implementation of the [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) interface, backed by a [HashMap](-hash-map/index#kotlin.collections.HashMap) instance. **Platform and version requirements:** ``` class HashSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` typealias HashSet<E> = HashSet<E> ``` **Platform and version requirements:** JS (1.1) ``` open class HashSet<E> : AbstractMutableSet<E>, MutableSet<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IndexedValue](-indexed-value/index) Data class representing a value from a collection or sequence, along with its index in that collection or sequence. ``` data class IndexedValue<out T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntIterator](-int-iterator/index) An iterator over a sequence of values of type `Int`. ``` abstract class IntIterator : Iterator<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Iterable](-iterable/index) Classes that inherit from this interface can be represented as a sequence of elements that can be iterated over. ``` interface Iterable<out T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Iterator](-iterator/index) An iterator over a collection or another entity that can be represented as a sequence of elements. Allows to sequentially access the elements. ``` interface Iterator<out T> ``` #### [LinkedHashMap](-linked-hash-map/index) Hash table based implementation of the [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) interface, which additionally preserves the insertion order of entries during the iteration. **Platform and version requirements:** ``` class LinkedHashMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` typealias LinkedHashMap<K, V> = LinkedHashMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` open class LinkedHashMap<K, V> :      HashMap<K, V>,     MutableMap<K, V> ``` #### [LinkedHashSet](-linked-hash-set/index) The implementation of the [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) interface, backed by a [LinkedHashMap](-linked-hash-map/index#kotlin.collections.LinkedHashMap) instance. **Platform and version requirements:** ``` class LinkedHashSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` typealias LinkedHashSet<E> = LinkedHashSet<E> ``` **Platform and version requirements:** JS (1.1) ``` open class LinkedHashSet<E> : HashSet<E>, MutableSet<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [List](-list/index) A generic ordered collection of elements. Methods in this interface support only read-only access to the list; read/write access is supported through the [MutableList](-mutable-list/index#kotlin.collections.MutableList) interface. ``` interface List<out E> : Collection<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ListIterator](-list-iterator/index) An iterator over a collection that supports indexed access. ``` interface ListIterator<out T> : Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongIterator](-long-iterator/index) An iterator over a sequence of values of type `Long`. ``` abstract class LongIterator : Iterator<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Map](-map/index) A collection that holds pairs of objects (keys and values) and supports efficiently retrieving the value corresponding to each key. Map keys are unique; the map holds only one value for each key. Methods in this interface support only read-only access to the map; read-write access is supported through the [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) interface. ``` interface Map<K, out V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableCollection](-mutable-collection/index) A generic collection of elements that supports adding and removing elements. ``` interface MutableCollection<E> :      Collection<E>,     MutableIterable<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableIterable](-mutable-iterable/index) Classes that inherit from this interface can be represented as a sequence of elements that can be iterated over and that supports removing elements during iteration. ``` interface MutableIterable<out T> : Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableIterator](-mutable-iterator/index) An iterator over a mutable collection. Provides the ability to remove elements while iterating. ``` interface MutableIterator<out T> : Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableList](-mutable-list/index) A generic ordered collection of elements that supports adding and removing elements. ``` interface MutableList<E> : List<E>, MutableCollection<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableListIterator](-mutable-list-iterator/index) An iterator over a mutable collection that supports indexed access. Provides the ability to add, modify and remove elements while iterating. ``` interface MutableListIterator<T> :      ListIterator<T>,     MutableIterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableMap](-mutable-map/index) A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving the value corresponding to each key. Map keys are unique; the map holds only one value for each key. ``` interface MutableMap<K, V> : Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableSet](-mutable-set/index) A generic unordered collection of elements that does not support duplicate elements, and supports adding and removing elements. ``` interface MutableSet<E> : Set<E>, MutableCollection<E> ``` #### [RandomAccess](-random-access) Marker interface indicating that the [List](-list/index#kotlin.collections.List) implementation supports fast indexed access. **Platform and version requirements:** JS (1.1) ``` interface RandomAccess ``` **Platform and version requirements:** JVM (1.1) ``` typealias RandomAccess = RandomAccess ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Set](-set/index) A generic unordered collection of elements that does not support duplicate elements. Methods in this interface support only read-only access to the set; read/write access is supported through the [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) interface. ``` interface Set<out E> : Collection<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ShortIterator](-short-iterator/index) An iterator over a sequence of values of type `Short`. ``` abstract class ShortIterator : Iterator<Short> ``` Extensions for External Classes ------------------------------- **Platform and version requirements:** JVM (1.0) #### [java.util.concurrent.ConcurrentMap](java.util.concurrent.-concurrent-map/index) **Platform and version requirements:** JVM (1.0) #### [java.util.Enumeration](java.util.-enumeration/index) Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <indices> Returns the range of valid indices for the array. ``` val <T> Array<out T>.indices: IntRange ``` ``` val ByteArray.indices: IntRange ``` ``` val ShortArray.indices: IntRange ``` ``` val IntArray.indices: IntRange ``` ``` val LongArray.indices: IntRange ``` ``` val FloatArray.indices: IntRange ``` ``` val DoubleArray.indices: IntRange ``` ``` val BooleanArray.indices: IntRange ``` ``` val CharArray.indices: IntRange ``` ``` val UIntArray.indices: IntRange ``` ``` val ULongArray.indices: IntRange ``` ``` val UByteArray.indices: IntRange ``` ``` val UShortArray.indices: IntRange ``` Returns an [IntRange](../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](last-index) Returns the last valid index for the array. ``` val <T> Array<out T>.lastIndex: Int ``` ``` val ByteArray.lastIndex: Int ``` ``` val ShortArray.lastIndex: Int ``` ``` val IntArray.lastIndex: Int ``` ``` val LongArray.lastIndex: Int ``` ``` val FloatArray.lastIndex: Int ``` ``` val DoubleArray.lastIndex: Int ``` ``` val BooleanArray.lastIndex: Int ``` ``` val CharArray.lastIndex: Int ``` ``` val UIntArray.lastIndex: Int ``` ``` val ULongArray.lastIndex: Int ``` ``` val UByteArray.lastIndex: Int ``` ``` val UShortArray.lastIndex: Int ``` Returns the index of the last item in the list or -1 if the list is empty. ``` val <T> List<T>.lastIndex: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](add-all) Adds all elements of the given [elements](add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### <aggregate> Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](aggregate#kotlin.collections%24aggregate(kotlin.collections.Grouping((kotlin.collections.aggregate.T,%20kotlin.collections.aggregate.K)),%20kotlin.Function4((kotlin.collections.aggregate.K,%20kotlin.collections.aggregate.R?,%20kotlin.collections.aggregate.T,%20kotlin.Boolean,%20kotlin.collections.aggregate.R)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. ``` fun <T, K, R> Grouping<T, K>.aggregate(     operation: (key: K, accumulator: R?, element: T, first: Boolean) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [aggregateTo](aggregate-to) Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](aggregate-to#kotlin.collections%24aggregateTo(kotlin.collections.Grouping((kotlin.collections.aggregateTo.T,%20kotlin.collections.aggregateTo.K)),%20kotlin.collections.aggregateTo.M,%20kotlin.Function4((kotlin.collections.aggregateTo.K,%20kotlin.collections.aggregateTo.R?,%20kotlin.collections.aggregateTo.T,%20kotlin.Boolean,%20kotlin.collections.aggregateTo.R)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](aggregate-to#kotlin.collections%24aggregateTo(kotlin.collections.Grouping((kotlin.collections.aggregateTo.T,%20kotlin.collections.aggregateTo.K)),%20kotlin.collections.aggregateTo.M,%20kotlin.Function4((kotlin.collections.aggregateTo.K,%20kotlin.collections.aggregateTo.R?,%20kotlin.collections.aggregateTo.T,%20kotlin.Boolean,%20kotlin.collections.aggregateTo.R)))/destination) map. ``` fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.aggregateTo(     destination: M,     operation: (key: K, accumulator: R?, element: T, first: Boolean) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <all> Returns `true` if all elements match the given [predicate](all#kotlin.collections%24all(kotlin.Array((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.all(predicate: (T) -> Boolean): Boolean ``` ``` fun ByteArray.all(predicate: (Byte) -> Boolean): Boolean ``` ``` fun ShortArray.all(predicate: (Short) -> Boolean): Boolean ``` ``` fun IntArray.all(predicate: (Int) -> Boolean): Boolean ``` ``` fun LongArray.all(predicate: (Long) -> Boolean): Boolean ``` ``` fun FloatArray.all(predicate: (Float) -> Boolean): Boolean ``` ``` fun DoubleArray.all(predicate: (Double) -> Boolean): Boolean ``` ``` fun BooleanArray.all(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.all(predicate: (Char) -> Boolean): Boolean ``` ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` ``` fun UIntArray.all(predicate: (UInt) -> Boolean): Boolean ``` ``` fun ULongArray.all(predicate: (ULong) -> Boolean): Boolean ``` ``` fun UByteArray.all(predicate: (UByte) -> Boolean): Boolean ``` ``` fun UShortArray.all(predicate: (UShort) -> Boolean): Boolean ``` Returns `true` if all entries match the given [predicate](all#kotlin.collections%24all(kotlin.collections.Map((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.all(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <any> Returns `true` if array has at least one element. ``` fun <T> Array<out T>.any(): Boolean ``` ``` fun ByteArray.any(): Boolean ``` ``` fun ShortArray.any(): Boolean ``` ``` fun IntArray.any(): Boolean ``` ``` fun LongArray.any(): Boolean ``` ``` fun FloatArray.any(): Boolean ``` ``` fun DoubleArray.any(): Boolean ``` ``` fun BooleanArray.any(): Boolean ``` ``` fun CharArray.any(): Boolean ``` ``` fun UIntArray.any(): Boolean ``` ``` fun ULongArray.any(): Boolean ``` ``` fun UByteArray.any(): Boolean ``` ``` fun UShortArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](any#kotlin.collections%24any(kotlin.Array((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.any(predicate: (T) -> Boolean): Boolean ``` ``` fun ByteArray.any(predicate: (Byte) -> Boolean): Boolean ``` ``` fun ShortArray.any(predicate: (Short) -> Boolean): Boolean ``` ``` fun IntArray.any(predicate: (Int) -> Boolean): Boolean ``` ``` fun LongArray.any(predicate: (Long) -> Boolean): Boolean ``` ``` fun FloatArray.any(predicate: (Float) -> Boolean): Boolean ``` ``` fun DoubleArray.any(predicate: (Double) -> Boolean): Boolean ``` ``` fun BooleanArray.any(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.any(predicate: (Char) -> Boolean): Boolean ``` ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` ``` fun UIntArray.any(predicate: (UInt) -> Boolean): Boolean ``` ``` fun ULongArray.any(predicate: (ULong) -> Boolean): Boolean ``` ``` fun UByteArray.any(predicate: (UByte) -> Boolean): Boolean ``` ``` fun UShortArray.any(predicate: (UShort) -> Boolean): Boolean ``` Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if map has at least one entry. ``` fun <K, V> Map<out K, V>.any(): Boolean ``` Returns `true` if at least one entry matches the given [predicate](any#kotlin.collections%24any(kotlin.collections.Map((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.any(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [arrayListOf](array-list-of) Returns an empty new [ArrayList](-array-list/index#kotlin.collections.ArrayList). ``` fun <T> arrayListOf(): ArrayList<T> ``` Returns a new [ArrayList](-array-list/index#kotlin.collections.ArrayList) with the given elements. ``` fun <T> arrayListOf(vararg elements: T): ArrayList<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asByteArray](as-byte-array) Returns an array of type [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun UByteArray.asByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asIntArray](as-int-array) Returns an array of type [IntArray](../kotlin/-int-array/index#kotlin.IntArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun UIntArray.asIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](as-iterable) Creates an [Iterable](-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun <T> any_array<T>.asIterable(): Iterable<T> ``` Returns this collection as an [Iterable](-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` Creates an [Iterable](-iterable/index#kotlin.collections.Iterable) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asList](as-list) Returns a [List](-list/index#kotlin.collections.List) that wraps the original array. ``` fun <T> Array<out T>.asList(): List<T> ``` ``` fun ByteArray.asList(): List<Byte> ``` ``` fun ShortArray.asList(): List<Short> ``` ``` fun IntArray.asList(): List<Int> ``` ``` fun LongArray.asList(): List<Long> ``` ``` fun FloatArray.asList(): List<Float> ``` ``` fun DoubleArray.asList(): List<Double> ``` ``` fun BooleanArray.asList(): List<Boolean> ``` ``` fun CharArray.asList(): List<Char> ``` ``` fun UIntArray.asList(): List<UInt> ``` ``` fun ULongArray.asList(): List<ULong> ``` ``` fun UByteArray.asList(): List<UByte> ``` ``` fun UShortArray.asList(): List<UShort> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asLongArray](as-long-array) Returns an array of type [LongArray](../kotlin/-long-array/index#kotlin.LongArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun ULongArray.asLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asReversed](as-reversed) Returns a reversed read-only view of the original List. All changes made in the original list will be reflected in the reversed one. ``` fun <T> List<T>.asReversed(): List<T> ``` Returns a reversed mutable view of the original mutable List. All changes made in the original list will be reflected in the reversed one and vice versa. ``` fun <T> MutableList<T>.asReversed(): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](as-sequence) Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original array returning its elements when being iterated. ``` fun <T> any_array<T>.asSequence(): Sequence<T> ``` Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asShortArray](as-short-array) Returns an array of type [ShortArray](../kotlin/-short-array/index#kotlin.ShortArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun UShortArray.asShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <associate> Returns a [Map](-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](associate#kotlin.collections%24associate(kotlin.Array((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <T, K, V> any_array<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](associate-by) Returns a [Map](-map/index#kotlin.collections.Map) containing the elements from the given array indexed by the key returned from [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.Array((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> any_array<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](associate-by#kotlin.collections%24associateBy(kotlin.Array((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.Array((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <T, K, V> any_array<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](associate-by-to) Populates and returns the [destination](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> any_array<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](associate-by-to#kotlin.collections%24associateByTo(kotlin.Array((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <T, K, V, M : MutableMap<in K, in V>> any_array<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` Populates and returns the [destination](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](associate-to) Populates and returns the [destination](associate-to#kotlin.collections%24associateTo(kotlin.Array((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](associate-to#kotlin.collections%24associateTo(kotlin.Array((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <T, K, V, M : MutableMap<in K, in V>> any_array<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` Populates and returns the [destination](associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](associate-with) Returns a [Map](-map/index#kotlin.collections.Map) where keys are elements from the given array and values are produced by the [valueSelector](associate-with#kotlin.collections%24associateWith(kotlin.Array((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Array<out K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` ``` fun <V> ByteArray.associateWith(     valueSelector: (Byte) -> V ): Map<Byte, V> ``` ``` fun <V> ShortArray.associateWith(     valueSelector: (Short) -> V ): Map<Short, V> ``` ``` fun <V> IntArray.associateWith(     valueSelector: (Int) -> V ): Map<Int, V> ``` ``` fun <V> LongArray.associateWith(     valueSelector: (Long) -> V ): Map<Long, V> ``` ``` fun <V> FloatArray.associateWith(     valueSelector: (Float) -> V ): Map<Float, V> ``` ``` fun <V> DoubleArray.associateWith(     valueSelector: (Double) -> V ): Map<Double, V> ``` ``` fun <V> BooleanArray.associateWith(     valueSelector: (Boolean) -> V ): Map<Boolean, V> ``` ``` fun <V> CharArray.associateWith(     valueSelector: (Char) -> V ): Map<Char, V> ``` ``` fun <V> UIntArray.associateWith(     valueSelector: (UInt) -> V ): Map<UInt, V> ``` ``` fun <V> ULongArray.associateWith(     valueSelector: (ULong) -> V ): Map<ULong, V> ``` ``` fun <V> UByteArray.associateWith(     valueSelector: (UByte) -> V ): Map<UByte, V> ``` ``` fun <V> UShortArray.associateWith(     valueSelector: (UShort) -> V ): Map<UShort, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](associate-with-to) Populates and returns the [destination](associate-with-to#kotlin.collections%24associateWithTo(kotlin.Array((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given array, where key is the element itself and value is provided by the [valueSelector](associate-with-to#kotlin.collections%24associateWithTo(kotlin.Array((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Array<out K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` ``` fun <V, M : MutableMap<in Byte, in V>> ByteArray.associateWithTo(     destination: M,     valueSelector: (Byte) -> V ): M ``` ``` fun <V, M : MutableMap<in Short, in V>> ShortArray.associateWithTo(     destination: M,     valueSelector: (Short) -> V ): M ``` ``` fun <V, M : MutableMap<in Int, in V>> IntArray.associateWithTo(     destination: M,     valueSelector: (Int) -> V ): M ``` ``` fun <V, M : MutableMap<in Long, in V>> LongArray.associateWithTo(     destination: M,     valueSelector: (Long) -> V ): M ``` ``` fun <V, M : MutableMap<in Float, in V>> FloatArray.associateWithTo(     destination: M,     valueSelector: (Float) -> V ): M ``` ``` fun <V, M : MutableMap<in Double, in V>> DoubleArray.associateWithTo(     destination: M,     valueSelector: (Double) -> V ): M ``` ``` fun <V, M : MutableMap<in Boolean, in V>> BooleanArray.associateWithTo(     destination: M,     valueSelector: (Boolean) -> V ): M ``` ``` fun <V, M : MutableMap<in Char, in V>> CharArray.associateWithTo(     destination: M,     valueSelector: (Char) -> V ): M ``` ``` fun <V, M : MutableMap<in UInt, in V>> UIntArray.associateWithTo(     destination: M,     valueSelector: (UInt) -> V ): M ``` ``` fun <V, M : MutableMap<in ULong, in V>> ULongArray.associateWithTo(     destination: M,     valueSelector: (ULong) -> V ): M ``` ``` fun <V, M : MutableMap<in UByte, in V>> UByteArray.associateWithTo(     destination: M,     valueSelector: (UByte) -> V ): M ``` ``` fun <V, M : MutableMap<in UShort, in V>> UShortArray.associateWithTo(     destination: M,     valueSelector: (UShort) -> V ): M ``` Populates and returns the [destination](associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asUByteArray](as-u-byte-array) Returns an array of type [UByteArray](../kotlin/-u-byte-array/index), which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array. ``` fun ByteArray.asUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asUIntArray](as-u-int-array) Returns an array of type [UIntArray](../kotlin/-u-int-array/index), which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array. ``` fun IntArray.asUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asULongArray](as-u-long-array) Returns an array of type [ULongArray](../kotlin/-u-long-array/index), which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array. ``` fun LongArray.asULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asUShortArray](as-u-short-array) Returns an array of type [UShortArray](../kotlin/-u-short-array/index), which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array. ``` fun ShortArray.asUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <average> Returns an average value of elements in the array. ``` fun Array<out Byte>.average(): Double ``` ``` fun Array<out Short>.average(): Double ``` ``` fun Array<out Int>.average(): Double ``` ``` fun Array<out Long>.average(): Double ``` ``` fun Array<out Float>.average(): Double ``` ``` fun Array<out Double>.average(): Double ``` ``` fun ByteArray.average(): Double ``` ``` fun ShortArray.average(): Double ``` ``` fun IntArray.average(): Double ``` ``` fun LongArray.average(): Double ``` ``` fun FloatArray.average(): Double ``` ``` fun DoubleArray.average(): Double ``` Returns an average value of elements in the collection. ``` fun Iterable<Byte>.average(): Double ``` ``` fun Iterable<Short>.average(): Double ``` ``` fun Iterable<Int>.average(): Double ``` ``` fun Iterable<Long>.average(): Double ``` ``` fun Iterable<Float>.average(): Double ``` ``` fun Iterable<Double>.average(): Double ``` #### [binarySearch](binary-search) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Searches this list or its range for the provided [element](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T?)),%20kotlin.collections.binarySearch.T?,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of its elements, otherwise the result is undefined. ``` fun <T : Comparable<T>> List<T?>.binarySearch(     element: T?,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Searches this list or its range for the provided [element](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Searches this list or its range for an element for which the given [comparison](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0) Searches the array or the range of the array for the provided [element](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted according to the specified [comparator](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> Array<out T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0) Searches the array or the range of the array for the provided [element](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun <T> Array<out T>.binarySearch(     element: T,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun ByteArray.binarySearch(     element: Byte,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun ShortArray.binarySearch(     element: Short,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun IntArray.binarySearch(     element: Int,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun LongArray.binarySearch(     element: Long,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun FloatArray.binarySearch(     element: Float,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun DoubleArray.binarySearch(     element: Double,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun CharArray.binarySearch(     element: Char,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun UIntArray.binarySearch(     element: UInt,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun ULongArray.binarySearch(     element: ULong,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun UByteArray.binarySearch(     element: UByte,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun UShortArray.binarySearch(     element: UShort,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearchBy](binary-search-by) Searches this list or its range for an element having the key returned by the specified [selector](binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. ``` fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     selector: (T) -> K? ): Int ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [buildList](build-list) Builds a new read-only [List](-list/index#kotlin.collections.List) by populating a [MutableList](-mutable-list/index#kotlin.collections.MutableList) using the given [builderAction](build-list#kotlin.collections%24buildList(kotlin.Function1((kotlin.collections.MutableList((kotlin.collections.buildList.E)),%20kotlin.Unit)))/builderAction) and returning a read-only list with the same elements. ``` fun <E> buildList(     builderAction: MutableList<E>.() -> Unit ): List<E> ``` ``` fun <E> buildList(     capacity: Int,     builderAction: MutableList<E>.() -> Unit ): List<E> ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [buildMap](build-map) Builds a new read-only [Map](-map/index#kotlin.collections.Map) by populating a [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) using the given [builderAction](build-map#kotlin.collections%24buildMap(kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/builderAction) and returning a read-only map with the same key-value pairs. ``` fun <K, V> buildMap(     builderAction: MutableMap<K, V>.() -> Unit ): Map<K, V> ``` ``` fun <K, V> buildMap(     capacity: Int,     builderAction: MutableMap<K, V>.() -> Unit ): Map<K, V> ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [buildSet](build-set) Builds a new read-only [Set](-set/index#kotlin.collections.Set) by populating a [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) using the given [builderAction](build-set#kotlin.collections%24buildSet(kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/builderAction) and returning a read-only set with the same elements. ``` fun <E> buildSet(     builderAction: MutableSet<E>.() -> Unit ): Set<E> ``` ``` fun <E> buildSet(     capacity: Int,     builderAction: MutableSet<E>.() -> Unit ): Set<E> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <chunked> Splits this collection into a list of lists each not exceeding the given [size](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <component1> Returns 1st *element* from the array. ``` operator fun <T> Array<out T>.component1(): T ``` ``` operator fun ByteArray.component1(): Byte ``` ``` operator fun ShortArray.component1(): Short ``` ``` operator fun IntArray.component1(): Int ``` ``` operator fun LongArray.component1(): Long ``` ``` operator fun FloatArray.component1(): Float ``` ``` operator fun DoubleArray.component1(): Double ``` ``` operator fun BooleanArray.component1(): Boolean ``` ``` operator fun CharArray.component1(): Char ``` ``` operator fun UIntArray.component1(): UInt ``` ``` operator fun ULongArray.component1(): ULong ``` ``` operator fun UByteArray.component1(): UByte ``` ``` operator fun UShortArray.component1(): UShort ``` Returns 1st *element* from the list. ``` operator fun <T> List<T>.component1(): T ``` Returns the key component of the map entry. ``` operator fun <K, V> Entry<K, V>.component1(): K ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <component2> Returns 2nd *element* from the array. ``` operator fun <T> Array<out T>.component2(): T ``` ``` operator fun ByteArray.component2(): Byte ``` ``` operator fun ShortArray.component2(): Short ``` ``` operator fun IntArray.component2(): Int ``` ``` operator fun LongArray.component2(): Long ``` ``` operator fun FloatArray.component2(): Float ``` ``` operator fun DoubleArray.component2(): Double ``` ``` operator fun BooleanArray.component2(): Boolean ``` ``` operator fun CharArray.component2(): Char ``` ``` operator fun UIntArray.component2(): UInt ``` ``` operator fun ULongArray.component2(): ULong ``` ``` operator fun UByteArray.component2(): UByte ``` ``` operator fun UShortArray.component2(): UShort ``` Returns 2nd *element* from the list. ``` operator fun <T> List<T>.component2(): T ``` Returns the value component of the map entry. ``` operator fun <K, V> Entry<K, V>.component2(): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <component3> Returns 3rd *element* from the array. ``` operator fun <T> Array<out T>.component3(): T ``` ``` operator fun ByteArray.component3(): Byte ``` ``` operator fun ShortArray.component3(): Short ``` ``` operator fun IntArray.component3(): Int ``` ``` operator fun LongArray.component3(): Long ``` ``` operator fun FloatArray.component3(): Float ``` ``` operator fun DoubleArray.component3(): Double ``` ``` operator fun BooleanArray.component3(): Boolean ``` ``` operator fun CharArray.component3(): Char ``` ``` operator fun UIntArray.component3(): UInt ``` ``` operator fun ULongArray.component3(): ULong ``` ``` operator fun UByteArray.component3(): UByte ``` ``` operator fun UShortArray.component3(): UShort ``` Returns 3rd *element* from the list. ``` operator fun <T> List<T>.component3(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <component4> Returns 4th *element* from the array. ``` operator fun <T> Array<out T>.component4(): T ``` ``` operator fun ByteArray.component4(): Byte ``` ``` operator fun ShortArray.component4(): Short ``` ``` operator fun IntArray.component4(): Int ``` ``` operator fun LongArray.component4(): Long ``` ``` operator fun FloatArray.component4(): Float ``` ``` operator fun DoubleArray.component4(): Double ``` ``` operator fun BooleanArray.component4(): Boolean ``` ``` operator fun CharArray.component4(): Char ``` ``` operator fun UIntArray.component4(): UInt ``` ``` operator fun ULongArray.component4(): ULong ``` ``` operator fun UByteArray.component4(): UByte ``` ``` operator fun UShortArray.component4(): UShort ``` Returns 4th *element* from the list. ``` operator fun <T> List<T>.component4(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <component5> Returns 5th *element* from the array. ``` operator fun <T> Array<out T>.component5(): T ``` ``` operator fun ByteArray.component5(): Byte ``` ``` operator fun ShortArray.component5(): Short ``` ``` operator fun IntArray.component5(): Int ``` ``` operator fun LongArray.component5(): Long ``` ``` operator fun FloatArray.component5(): Float ``` ``` operator fun DoubleArray.component5(): Double ``` ``` operator fun BooleanArray.component5(): Boolean ``` ``` operator fun CharArray.component5(): Char ``` ``` operator fun UIntArray.component5(): UInt ``` ``` operator fun ULongArray.component5(): ULong ``` ``` operator fun UByteArray.component5(): UByte ``` ``` operator fun UShortArray.component5(): UShort ``` Returns 5th *element* from the list. ``` operator fun <T> List<T>.component5(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Returns `true` if [element](contains#kotlin.collections%24contains(kotlin.Array((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the array. ``` operator fun <T> any_array<T>.contains(element: T): Boolean ``` Returns `true` if [element](contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` Checks if the map contains the given key. ``` operator fun <K, V> Map<out K, V>.contains(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](contains-key) Returns `true` if the map contains the specified [key](contains-key#kotlin.collections%24containsKey(kotlin.collections.Map((kotlin.collections.containsKey.K,%20kotlin.Any?)),%20kotlin.collections.containsKey.K)/key). ``` fun <K> Map<out K, *>.containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](contains-value) Returns `true` if the map maps one or more keys to the specified [value](contains-value#kotlin.collections%24containsValue(kotlin.collections.Map((kotlin.collections.containsValue.K,%20kotlin.collections.containsValue.V)),%20kotlin.collections.containsValue.V)/value). ``` fun <K, V> Map<K, V>.containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [contentDeepEquals](content-deep-equals) Returns `true` if the two specified arrays are *deeply* equal to one another, i.e. contain the same number of the same elements in the same order. ``` infix fun <T> any_array<T>.contentDeepEquals(     other: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [contentDeepHashCode](content-deep-hash-code) Returns a hash code based on the contents of this array as if it is [List](-list/index#kotlin.collections.List). Nested arrays are treated as lists too. ``` fun <T> any_array<T>.contentDeepHashCode(): Int ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [contentDeepToString](content-deep-to-string) Returns a string representation of the contents of this array as if it is a [List](-list/index#kotlin.collections.List). Nested arrays are treated as lists too. ``` fun <T> any_array<T>.contentDeepToString(): String ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [contentEquals](content-equals) Returns `true` if the two specified arrays are *structurally* equal to one another, i.e. contain the same number of the same elements in the same order. ``` infix fun UIntArray.contentEquals(other: UIntArray): Boolean ``` ``` infix fun ULongArray.contentEquals(     other: ULongArray ): Boolean ``` ``` infix fun UByteArray.contentEquals(     other: UByteArray ): Boolean ``` ``` infix fun UShortArray.contentEquals(     other: UShortArray ): Boolean ``` ``` infix fun UIntArray?.contentEquals(     other: UIntArray? ): Boolean ``` ``` infix fun ULongArray?.contentEquals(     other: ULongArray? ): Boolean ``` ``` infix fun UByteArray?.contentEquals(     other: UByteArray? ): Boolean ``` ``` infix fun UShortArray?.contentEquals(     other: UShortArray? ): Boolean ``` ``` infix fun <T> Array<out T>.contentEquals(     other: Array<out T> ): Boolean ``` ``` infix fun ByteArray.contentEquals(other: ByteArray): Boolean ``` ``` infix fun ShortArray.contentEquals(     other: ShortArray ): Boolean ``` ``` infix fun IntArray.contentEquals(other: IntArray): Boolean ``` ``` infix fun LongArray.contentEquals(other: LongArray): Boolean ``` ``` infix fun FloatArray.contentEquals(     other: FloatArray ): Boolean ``` ``` infix fun DoubleArray.contentEquals(     other: DoubleArray ): Boolean ``` ``` infix fun BooleanArray.contentEquals(     other: BooleanArray ): Boolean ``` ``` infix fun CharArray.contentEquals(other: CharArray): Boolean ``` ``` infix fun <T> Array<out T>?.contentEquals(     other: Array<out T>? ): Boolean ``` ``` infix fun ByteArray?.contentEquals(     other: ByteArray? ): Boolean ``` ``` infix fun ShortArray?.contentEquals(     other: ShortArray? ): Boolean ``` ``` infix fun IntArray?.contentEquals(other: IntArray?): Boolean ``` ``` infix fun LongArray?.contentEquals(     other: LongArray? ): Boolean ``` ``` infix fun FloatArray?.contentEquals(     other: FloatArray? ): Boolean ``` ``` infix fun DoubleArray?.contentEquals(     other: DoubleArray? ): Boolean ``` ``` infix fun BooleanArray?.contentEquals(     other: BooleanArray? ): Boolean ``` ``` infix fun CharArray?.contentEquals(     other: CharArray? ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [contentHashCode](content-hash-code) Returns a hash code based on the contents of this array as if it is [List](-list/index#kotlin.collections.List). ``` fun UIntArray.contentHashCode(): Int ``` ``` fun ULongArray.contentHashCode(): Int ``` ``` fun UByteArray.contentHashCode(): Int ``` ``` fun UShortArray.contentHashCode(): Int ``` ``` fun UIntArray?.contentHashCode(): Int ``` ``` fun ULongArray?.contentHashCode(): Int ``` ``` fun UByteArray?.contentHashCode(): Int ``` ``` fun UShortArray?.contentHashCode(): Int ``` ``` fun <T> Array<out T>.contentHashCode(): Int ``` ``` fun ByteArray.contentHashCode(): Int ``` ``` fun ShortArray.contentHashCode(): Int ``` ``` fun IntArray.contentHashCode(): Int ``` ``` fun LongArray.contentHashCode(): Int ``` ``` fun FloatArray.contentHashCode(): Int ``` ``` fun DoubleArray.contentHashCode(): Int ``` ``` fun BooleanArray.contentHashCode(): Int ``` ``` fun CharArray.contentHashCode(): Int ``` ``` fun <T> Array<out T>?.contentHashCode(): Int ``` ``` fun ByteArray?.contentHashCode(): Int ``` ``` fun ShortArray?.contentHashCode(): Int ``` ``` fun IntArray?.contentHashCode(): Int ``` ``` fun LongArray?.contentHashCode(): Int ``` ``` fun FloatArray?.contentHashCode(): Int ``` ``` fun DoubleArray?.contentHashCode(): Int ``` ``` fun BooleanArray?.contentHashCode(): Int ``` ``` fun CharArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [contentToString](content-to-string) Returns a string representation of the contents of the specified array as if it is [List](-list/index#kotlin.collections.List). ``` fun UIntArray.contentToString(): String ``` ``` fun ULongArray.contentToString(): String ``` ``` fun UByteArray.contentToString(): String ``` ``` fun UShortArray.contentToString(): String ``` ``` fun UIntArray?.contentToString(): String ``` ``` fun ULongArray?.contentToString(): String ``` ``` fun UByteArray?.contentToString(): String ``` ``` fun UShortArray?.contentToString(): String ``` ``` fun <T> Array<out T>.contentToString(): String ``` ``` fun ByteArray.contentToString(): String ``` ``` fun ShortArray.contentToString(): String ``` ``` fun IntArray.contentToString(): String ``` ``` fun LongArray.contentToString(): String ``` ``` fun FloatArray.contentToString(): String ``` ``` fun DoubleArray.contentToString(): String ``` ``` fun BooleanArray.contentToString(): String ``` ``` fun CharArray.contentToString(): String ``` ``` fun <T> Array<out T>?.contentToString(): String ``` ``` fun ByteArray?.contentToString(): String ``` ``` fun ShortArray?.contentToString(): String ``` ``` fun IntArray?.contentToString(): String ``` ``` fun LongArray?.contentToString(): String ``` ``` fun FloatArray?.contentToString(): String ``` ``` fun DoubleArray?.contentToString(): String ``` ``` fun BooleanArray?.contentToString(): String ``` ``` fun CharArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [copyInto](copy-into) Copies this array or its subrange into the [destination](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array and returns that array. ``` fun UIntArray.copyInto(     destination: UIntArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): UIntArray ``` ``` fun ULongArray.copyInto(     destination: ULongArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): ULongArray ``` ``` fun UByteArray.copyInto(     destination: UByteArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): UByteArray ``` ``` fun UShortArray.copyInto(     destination: UShortArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): UShortArray ``` ``` fun <T> Array<out T>.copyInto(     destination: Array<T>,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): Array<T> ``` ``` fun ByteArray.copyInto(     destination: ByteArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): ByteArray ``` ``` fun ShortArray.copyInto(     destination: ShortArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): ShortArray ``` ``` fun IntArray.copyInto(     destination: IntArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): IntArray ``` ``` fun LongArray.copyInto(     destination: LongArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): LongArray ``` ``` fun FloatArray.copyInto(     destination: FloatArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): FloatArray ``` ``` fun DoubleArray.copyInto(     destination: DoubleArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): DoubleArray ``` ``` fun BooleanArray.copyInto(     destination: BooleanArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): BooleanArray ``` ``` fun CharArray.copyInto(     destination: CharArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): CharArray ``` #### [copyOf](copy-of) Returns new array which is a copy of the original array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UIntArray.copyOf(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun ULongArray.copyOf(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UByteArray.copyOf(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UShortArray.copyOf(): UShortArray ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` fun <T> Array<T>.copyOf(): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> Array<out T>.copyOf(): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun ByteArray.copyOf(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun ShortArray.copyOf(): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun IntArray.copyOf(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun LongArray.copyOf(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun FloatArray.copyOf(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun DoubleArray.copyOf(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun BooleanArray.copyOf(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun CharArray.copyOf(): CharArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.UIntArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with zero values if necessary. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UIntArray.copyOf(newSize: Int): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun ULongArray.copyOf(newSize: Int): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UByteArray.copyOf(newSize: Int): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UShortArray.copyOf(newSize: Int): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun ByteArray.copyOf(newSize: Int): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun ShortArray.copyOf(newSize: Int): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun IntArray.copyOf(newSize: Int): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun LongArray.copyOf(newSize: Int): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun FloatArray.copyOf(newSize: Int): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun DoubleArray.copyOf(newSize: Int): DoubleArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.BooleanArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with `false` values if necessary. **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun BooleanArray.copyOf(newSize: Int): BooleanArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.CharArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with null char (`\u0000`) values if necessary. **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun CharArray.copyOf(newSize: Int): CharArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](copy-of#kotlin.collections%24copyOf(kotlin.Array((kotlin.collections.copyOf.T)),%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with `null` values if necessary. **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun <T> any_array<T>.copyOf(newSize: Int): Array<T?> ``` #### [copyOfRange](copy-of-range) Returns a new array which is a copy of the specified range of the original array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UIntArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun ULongArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UByteArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun UShortArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UShortArray ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` fun <T> Array<T>.copyOfRange(     fromIndex: Int,     toIndex: Int ): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> Array<out T>.copyOfRange(     fromIndex: Int,     toIndex: Int ): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun ByteArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun ShortArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun IntArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun LongArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun FloatArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun DoubleArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun BooleanArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun CharArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <count> Returns the number of elements in this array. ``` fun <T> any_array<T>.count(): Int ``` Returns the number of elements matching the given [predicate](count#kotlin.collections%24count(kotlin.Array((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.count(predicate: (T) -> Boolean): Int ``` ``` fun ByteArray.count(predicate: (Byte) -> Boolean): Int ``` ``` fun ShortArray.count(predicate: (Short) -> Boolean): Int ``` ``` fun IntArray.count(predicate: (Int) -> Boolean): Int ``` ``` fun LongArray.count(predicate: (Long) -> Boolean): Int ``` ``` fun FloatArray.count(predicate: (Float) -> Boolean): Int ``` ``` fun DoubleArray.count(predicate: (Double) -> Boolean): Int ``` ``` fun BooleanArray.count(predicate: (Boolean) -> Boolean): Int ``` ``` fun CharArray.count(predicate: (Char) -> Boolean): Int ``` ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` ``` fun UIntArray.count(predicate: (UInt) -> Boolean): Int ``` ``` fun ULongArray.count(predicate: (ULong) -> Boolean): Int ``` ``` fun UByteArray.count(predicate: (UByte) -> Boolean): Int ``` ``` fun UShortArray.count(predicate: (UShort) -> Boolean): Int ``` Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` ``` fun <T> Collection<T>.count(): Int ``` Returns the number of entries in this map. ``` fun <K, V> Map<out K, V>.count(): Int ``` Returns the number of entries matching the given [predicate](count#kotlin.collections%24count(kotlin.collections.Map((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.count(     predicate: (Entry<K, V>) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <distinct> Returns a list containing only distinct elements from the given array. ``` fun <T> any_array<T>.distinct(): List<T> ``` Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](distinct-by) Returns a list containing only elements from the given array having distinct keys returned by the given [selector](distinct-by#kotlin.collections%24distinctBy(kotlin.Array((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> any_array<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](distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <drop> Returns a list containing all elements except first [n](drop#kotlin.collections%24drop(kotlin.Array((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Array<out T>.drop(n: Int): List<T> ``` ``` fun ByteArray.drop(n: Int): List<Byte> ``` ``` fun ShortArray.drop(n: Int): List<Short> ``` ``` fun IntArray.drop(n: Int): List<Int> ``` ``` fun LongArray.drop(n: Int): List<Long> ``` ``` fun FloatArray.drop(n: Int): List<Float> ``` ``` fun DoubleArray.drop(n: Int): List<Double> ``` ``` fun BooleanArray.drop(n: Int): List<Boolean> ``` ``` fun CharArray.drop(n: Int): List<Char> ``` ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` ``` fun UIntArray.drop(n: Int): List<UInt> ``` ``` fun ULongArray.drop(n: Int): List<ULong> ``` ``` fun UByteArray.drop(n: Int): List<UByte> ``` ``` fun UShortArray.drop(n: Int): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](drop-last) Returns a list containing all elements except last [n](drop-last#kotlin.collections%24dropLast(kotlin.Array((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> Array<out T>.dropLast(n: Int): List<T> ``` ``` fun ByteArray.dropLast(n: Int): List<Byte> ``` ``` fun ShortArray.dropLast(n: Int): List<Short> ``` ``` fun IntArray.dropLast(n: Int): List<Int> ``` ``` fun LongArray.dropLast(n: Int): List<Long> ``` ``` fun FloatArray.dropLast(n: Int): List<Float> ``` ``` fun DoubleArray.dropLast(n: Int): List<Double> ``` ``` fun BooleanArray.dropLast(n: Int): List<Boolean> ``` ``` fun CharArray.dropLast(n: Int): List<Char> ``` ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` ``` fun UIntArray.dropLast(n: Int): List<UInt> ``` ``` fun ULongArray.dropLast(n: Int): List<ULong> ``` ``` fun UByteArray.dropLast(n: Int): List<UByte> ``` ``` fun UShortArray.dropLast(n: Int): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](drop-last-while#kotlin.collections%24dropLastWhile(kotlin.Array((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` fun ByteArray.dropLastWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` fun ShortArray.dropLastWhile(     predicate: (Short) -> Boolean ): List<Short> ``` ``` fun IntArray.dropLastWhile(     predicate: (Int) -> Boolean ): List<Int> ``` ``` fun LongArray.dropLastWhile(     predicate: (Long) -> Boolean ): List<Long> ``` ``` fun FloatArray.dropLastWhile(     predicate: (Float) -> Boolean ): List<Float> ``` ``` fun DoubleArray.dropLastWhile(     predicate: (Double) -> Boolean ): List<Double> ``` ``` fun BooleanArray.dropLastWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.dropLastWhile(     predicate: (Char) -> Boolean ): List<Char> ``` ``` fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` fun UIntArray.dropLastWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` fun ULongArray.dropLastWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun UByteArray.dropLastWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` fun UShortArray.dropLastWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](drop-while#kotlin.collections%24dropWhile(kotlin.Array((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` fun ByteArray.dropWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` fun ShortArray.dropWhile(     predicate: (Short) -> Boolean ): List<Short> ``` ``` fun IntArray.dropWhile(     predicate: (Int) -> Boolean ): List<Int> ``` ``` fun LongArray.dropWhile(     predicate: (Long) -> Boolean ): List<Long> ``` ``` fun FloatArray.dropWhile(     predicate: (Float) -> Boolean ): List<Float> ``` ``` fun DoubleArray.dropWhile(     predicate: (Double) -> Boolean ): List<Double> ``` ``` fun BooleanArray.dropWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.dropWhile(     predicate: (Char) -> Boolean ): List<Char> ``` ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` fun UIntArray.dropWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` fun ULongArray.dropWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun UByteArray.dropWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` fun UShortArray.dropWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [eachCount](each-count) Groups elements from the Grouping source by key and counts elements in each group. ``` fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [eachCountTo](each-count-to) Groups elements from the [Grouping](-grouping/index) source by key and counts elements in each group to the given [destination](each-count-to#kotlin.collections%24eachCountTo(kotlin.collections.Grouping((kotlin.collections.eachCountTo.T,%20kotlin.collections.eachCountTo.K)),%20kotlin.collections.eachCountTo.M)/destination) map. ``` fun <T, K, M : MutableMap<in K, Int>> Grouping<T, K>.eachCountTo(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](element-at) Returns an element at the given [index](element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` Returns an element at the given [index](element-at#kotlin.collections%24elementAt(kotlin.collections.List((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.collections%24elementAt(kotlin.collections.List((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.elementAt(index: Int): T ``` Returns an element at the given [index](element-at#kotlin.collections%24elementAt(kotlin.Array((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.collections%24elementAt(kotlin.Array((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this array. ``` fun <T> Array<out T>.elementAt(index: Int): T ``` ``` fun ByteArray.elementAt(index: Int): Byte ``` ``` fun ShortArray.elementAt(index: Int): Short ``` ``` fun IntArray.elementAt(index: Int): Int ``` ``` fun LongArray.elementAt(index: Int): Long ``` ``` fun FloatArray.elementAt(index: Int): Float ``` ``` fun DoubleArray.elementAt(index: Int): Double ``` ``` fun BooleanArray.elementAt(index: Int): Boolean ``` ``` fun CharArray.elementAt(index: Int): Char ``` ``` fun UIntArray.elementAt(index: Int): UInt ``` ``` fun ULongArray.elementAt(index: Int): ULong ``` ``` fun UByteArray.elementAt(index: Int): UByte ``` ``` fun UShortArray.elementAt(index: Int): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](element-at-or-else) Returns an element at the given [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.Array((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.Array((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.Array((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this array. ``` fun <T> Array<out T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` ``` fun ByteArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Byte ): Byte ``` ``` fun ShortArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Short ): Short ``` ``` fun IntArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Int ): Int ``` ``` fun LongArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Long ): Long ``` ``` fun FloatArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Float ): Float ``` ``` fun DoubleArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Double ): Double ``` ``` fun BooleanArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Boolean ): Boolean ``` ``` fun CharArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` ``` fun UIntArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UInt ): UInt ``` ``` fun ULongArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> ULong ): ULong ``` ``` fun UByteArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UByte ): UByte ``` ``` fun UShortArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UShort ): UShort ``` Returns an element at the given [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](element-at-or-null) Returns an element at the given [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.Array((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.Array((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this array. ``` fun <T> Array<out T>.elementAtOrNull(index: Int): T? ``` ``` fun ByteArray.elementAtOrNull(index: Int): Byte? ``` ``` fun ShortArray.elementAtOrNull(index: Int): Short? ``` ``` fun IntArray.elementAtOrNull(index: Int): Int? ``` ``` fun LongArray.elementAtOrNull(index: Int): Long? ``` ``` fun FloatArray.elementAtOrNull(index: Int): Float? ``` ``` fun DoubleArray.elementAtOrNull(index: Int): Double? ``` ``` fun BooleanArray.elementAtOrNull(index: Int): Boolean? ``` ``` fun CharArray.elementAtOrNull(index: Int): Char? ``` ``` fun UIntArray.elementAtOrNull(index: Int): UInt? ``` ``` fun ULongArray.elementAtOrNull(index: Int): ULong? ``` ``` fun UByteArray.elementAtOrNull(index: Int): UByte? ``` ``` fun UShortArray.elementAtOrNull(index: Int): UShort? ``` Returns an element at the given [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` Returns an element at the given [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.List((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.List((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [emptyList](empty-list) Returns an empty read-only list. The returned list is serializable (JVM). ``` fun <T> emptyList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [emptyMap](empty-map) Returns an empty read-only map of specified type. ``` fun <K, V> emptyMap(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [emptySet](empty-set) Returns an empty read-only set. The returned set is serializable (JVM). ``` fun <T> emptySet(): Set<T> ``` #### <fill> **Platform and version requirements:** JVM (1.0), JS (1.3), Native (1.3) Fills this array or its subrange with the specified [element](fill#kotlin.collections%24fill(kotlin.UIntArray,%20kotlin.UInt,%20kotlin.Int,%20kotlin.Int)/element) value. ``` fun UIntArray.fill(     element: UInt,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun ULongArray.fill(     element: ULong,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun UByteArray.fill(     element: UByte,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun UShortArray.fill(     element: UShort,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun <T> Array<T>.fill(     element: T,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun ByteArray.fill(     element: Byte,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun ShortArray.fill(     element: Short,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun IntArray.fill(     element: Int,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun LongArray.fill(     element: Long,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun FloatArray.fill(     element: Float,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun DoubleArray.fill(     element: Double,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun BooleanArray.fill(     element: Boolean,     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun CharArray.fill(     element: Char,     fromIndex: Int = 0,     toIndex: Int = size) ``` **Platform and version requirements:** JVM (1.2), JS (1.2) Fills the list with the provided [value](fill#kotlin.collections%24fill(kotlin.collections.MutableList((kotlin.collections.fill.T)),%20kotlin.collections.fill.T)/value). ``` fun <T> MutableList<T>.fill(value: T) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <filter> Returns a list containing only elements matching the given [predicate](filter#kotlin.collections%24filter(kotlin.Array((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.filter(     predicate: (T) -> Boolean ): List<T> ``` ``` fun ByteArray.filter(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` fun ShortArray.filter(     predicate: (Short) -> Boolean ): List<Short> ``` ``` fun IntArray.filter(predicate: (Int) -> Boolean): List<Int> ``` ``` fun LongArray.filter(     predicate: (Long) -> Boolean ): List<Long> ``` ``` fun FloatArray.filter(     predicate: (Float) -> Boolean ): List<Float> ``` ``` fun DoubleArray.filter(     predicate: (Double) -> Boolean ): List<Double> ``` ``` fun BooleanArray.filter(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.filter(     predicate: (Char) -> Boolean ): List<Char> ``` ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` ``` fun UIntArray.filter(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` fun ULongArray.filter(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun UByteArray.filter(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` fun UShortArray.filter(     predicate: (UShort) -> Boolean ): List<UShort> ``` Returns a new map containing all key-value pairs matching the given [predicate](filter#kotlin.collections%24filter(kotlin.collections.Map((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filter(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](filter-indexed) Returns a list containing only elements matching the given [predicate](filter-indexed#kotlin.collections%24filterIndexed(kotlin.Array((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` ``` fun ByteArray.filterIndexed(     predicate: (index: Int, Byte) -> Boolean ): List<Byte> ``` ``` fun ShortArray.filterIndexed(     predicate: (index: Int, Short) -> Boolean ): List<Short> ``` ``` fun IntArray.filterIndexed(     predicate: (index: Int, Int) -> Boolean ): List<Int> ``` ``` fun LongArray.filterIndexed(     predicate: (index: Int, Long) -> Boolean ): List<Long> ``` ``` fun FloatArray.filterIndexed(     predicate: (index: Int, Float) -> Boolean ): List<Float> ``` ``` fun DoubleArray.filterIndexed(     predicate: (index: Int, Double) -> Boolean ): List<Double> ``` ``` fun BooleanArray.filterIndexed(     predicate: (index: Int, Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.filterIndexed(     predicate: (index: Int, Char) -> Boolean ): List<Char> ``` ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` ``` fun UIntArray.filterIndexed(     predicate: (index: Int, UInt) -> Boolean ): List<UInt> ``` ``` fun ULongArray.filterIndexed(     predicate: (index: Int, ULong) -> Boolean ): List<ULong> ``` ``` fun UByteArray.filterIndexed(     predicate: (index: Int, UByte) -> Boolean ): List<UByte> ``` ``` fun UShortArray.filterIndexed(     predicate: (index: Int, UShort) -> Boolean ): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](filter-indexed-to) Appends all elements matching the given [predicate](filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.Array((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.Array((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Array<out T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Byte>> ByteArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Byte) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Short>> ShortArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Short) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Int>> IntArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Int) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Long>> LongArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Long) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Float>> FloatArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Float) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Double>> DoubleArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Double) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Boolean>> BooleanArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Boolean) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Char>> CharArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Char) -> Boolean ): C ``` ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UInt>> UIntArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UInt) -> Boolean ): C ``` ``` fun <C : MutableCollection<in ULong>> ULongArray.filterIndexedTo(     destination: C,     predicate: (index: Int, ULong) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UByte>> UByteArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UByte) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UShort>> UShortArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UShort) -> Boolean ): C ``` #### [filterIsInstance](filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Array<*>.filterIsInstance(): List<R> ``` ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Array<*>.filterIsInstance(klass: Class<R>): List<R> ``` ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.Array((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Array<*>.filterIsInstanceTo(     destination: C ): C ``` ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.Array((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Array<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterKeys](filter-keys) Returns a map containing all key-value pairs with keys matching the given [predicate](filter-keys#kotlin.collections%24filterKeys(kotlin.collections.Map((kotlin.collections.filterKeys.K,%20kotlin.collections.filterKeys.V)),%20kotlin.Function1((kotlin.collections.filterKeys.K,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterKeys(     predicate: (K) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](filter-not) Returns a list containing all elements not matching the given [predicate](filter-not#kotlin.collections%24filterNot(kotlin.Array((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` ``` fun ByteArray.filterNot(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` fun ShortArray.filterNot(     predicate: (Short) -> Boolean ): List<Short> ``` ``` fun IntArray.filterNot(     predicate: (Int) -> Boolean ): List<Int> ``` ``` fun LongArray.filterNot(     predicate: (Long) -> Boolean ): List<Long> ``` ``` fun FloatArray.filterNot(     predicate: (Float) -> Boolean ): List<Float> ``` ``` fun DoubleArray.filterNot(     predicate: (Double) -> Boolean ): List<Double> ``` ``` fun BooleanArray.filterNot(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.filterNot(     predicate: (Char) -> Boolean ): List<Char> ``` ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` ``` fun UIntArray.filterNot(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` fun ULongArray.filterNot(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun UByteArray.filterNot(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` fun UShortArray.filterNot(     predicate: (UShort) -> Boolean ): List<UShort> ``` Returns a new map containing all key-value pairs not matching the given [predicate](filter-not#kotlin.collections%24filterNot(kotlin.collections.Map((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterNot(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Array<out T?>.filterNotNull(): List<T> ``` ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](filter-not-null-to) Appends all elements that are not `null` to the given [destination](filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.Array((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Array<out T?>.filterNotNullTo(     destination: C ): C ``` ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](filter-not-to) Appends all elements not matching the given [predicate](filter-not-to#kotlin.collections%24filterNotTo(kotlin.Array((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-not-to#kotlin.collections%24filterNotTo(kotlin.Array((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Array<out T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Byte>> ByteArray.filterNotTo(     destination: C,     predicate: (Byte) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Short>> ShortArray.filterNotTo(     destination: C,     predicate: (Short) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Int>> IntArray.filterNotTo(     destination: C,     predicate: (Int) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Long>> LongArray.filterNotTo(     destination: C,     predicate: (Long) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Float>> FloatArray.filterNotTo(     destination: C,     predicate: (Float) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Double>> DoubleArray.filterNotTo(     destination: C,     predicate: (Double) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Boolean>> BooleanArray.filterNotTo(     destination: C,     predicate: (Boolean) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Char>> CharArray.filterNotTo(     destination: C,     predicate: (Char) -> Boolean ): C ``` ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UInt>> UIntArray.filterNotTo(     destination: C,     predicate: (UInt) -> Boolean ): C ``` ``` fun <C : MutableCollection<in ULong>> ULongArray.filterNotTo(     destination: C,     predicate: (ULong) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UByte>> UByteArray.filterNotTo(     destination: C,     predicate: (UByte) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UShort>> UShortArray.filterNotTo(     destination: C,     predicate: (UShort) -> Boolean ): C ``` Appends all entries not matching the given [predicate](filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/predicate) into the given [destination](filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/destination). ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](filter-to) Appends all elements matching the given [predicate](filter-to#kotlin.collections%24filterTo(kotlin.Array((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-to#kotlin.collections%24filterTo(kotlin.Array((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Array<out T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Byte>> ByteArray.filterTo(     destination: C,     predicate: (Byte) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Short>> ShortArray.filterTo(     destination: C,     predicate: (Short) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Int>> IntArray.filterTo(     destination: C,     predicate: (Int) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Long>> LongArray.filterTo(     destination: C,     predicate: (Long) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Float>> FloatArray.filterTo(     destination: C,     predicate: (Float) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Double>> DoubleArray.filterTo(     destination: C,     predicate: (Double) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Boolean>> BooleanArray.filterTo(     destination: C,     predicate: (Boolean) -> Boolean ): C ``` ``` fun <C : MutableCollection<in Char>> CharArray.filterTo(     destination: C,     predicate: (Char) -> Boolean ): C ``` ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UInt>> UIntArray.filterTo(     destination: C,     predicate: (UInt) -> Boolean ): C ``` ``` fun <C : MutableCollection<in ULong>> ULongArray.filterTo(     destination: C,     predicate: (ULong) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UByte>> UByteArray.filterTo(     destination: C,     predicate: (UByte) -> Boolean ): C ``` ``` fun <C : MutableCollection<in UShort>> UShortArray.filterTo(     destination: C,     predicate: (UShort) -> Boolean ): C ``` Appends all entries matching the given [predicate](filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/predicate) into the mutable map given as [destination](filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/destination) parameter. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterValues](filter-values) Returns a map containing all key-value pairs with values matching the given [predicate](filter-values#kotlin.collections%24filterValues(kotlin.collections.Map((kotlin.collections.filterValues.K,%20kotlin.collections.filterValues.V)),%20kotlin.Function1((kotlin.collections.filterValues.V,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterValues(     predicate: (V) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <find> Returns the first element matching the given [predicate](find#kotlin.collections%24find(kotlin.Array((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Array<out T>.find(predicate: (T) -> Boolean): T? ``` ``` fun ByteArray.find(predicate: (Byte) -> Boolean): Byte? ``` ``` fun ShortArray.find(predicate: (Short) -> Boolean): Short? ``` ``` fun IntArray.find(predicate: (Int) -> Boolean): Int? ``` ``` fun LongArray.find(predicate: (Long) -> Boolean): Long? ``` ``` fun FloatArray.find(predicate: (Float) -> Boolean): Float? ``` ``` fun DoubleArray.find(predicate: (Double) -> Boolean): Double? ``` ``` fun BooleanArray.find(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.find(predicate: (Char) -> Boolean): Char? ``` ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` ``` fun UIntArray.find(predicate: (UInt) -> Boolean): UInt? ``` ``` fun ULongArray.find(predicate: (ULong) -> Boolean): ULong? ``` ``` fun UByteArray.find(predicate: (UByte) -> Boolean): UByte? ``` ``` fun UShortArray.find(predicate: (UShort) -> Boolean): UShort? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](find-last) Returns the last element matching the given [predicate](find-last#kotlin.collections%24findLast(kotlin.Array((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Array<out T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun ByteArray.findLast(predicate: (Byte) -> Boolean): Byte? ``` ``` fun ShortArray.findLast(     predicate: (Short) -> Boolean ): Short? ``` ``` fun IntArray.findLast(predicate: (Int) -> Boolean): Int? ``` ``` fun LongArray.findLast(predicate: (Long) -> Boolean): Long? ``` ``` fun FloatArray.findLast(     predicate: (Float) -> Boolean ): Float? ``` ``` fun DoubleArray.findLast(     predicate: (Double) -> Boolean ): Double? ``` ``` fun BooleanArray.findLast(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.findLast(predicate: (Char) -> Boolean): Char? ``` ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun UIntArray.findLast(predicate: (UInt) -> Boolean): UInt? ``` ``` fun ULongArray.findLast(     predicate: (ULong) -> Boolean ): ULong? ``` ``` fun UByteArray.findLast(     predicate: (UByte) -> Boolean ): UByte? ``` ``` fun UShortArray.findLast(     predicate: (UShort) -> Boolean ): UShort? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> Returns the first element. ``` fun <T> Array<out T>.first(): T ``` ``` fun ByteArray.first(): Byte ``` ``` fun ShortArray.first(): Short ``` ``` fun IntArray.first(): Int ``` ``` fun LongArray.first(): Long ``` ``` fun FloatArray.first(): Float ``` ``` fun DoubleArray.first(): Double ``` ``` fun BooleanArray.first(): Boolean ``` ``` fun CharArray.first(): Char ``` ``` fun <T> Iterable<T>.first(): T ``` ``` fun <T> List<T>.first(): T ``` ``` fun UIntArray.first(): UInt ``` ``` fun ULongArray.first(): ULong ``` ``` fun UByteArray.first(): UByte ``` ``` fun UShortArray.first(): UShort ``` Returns the first element matching the given [predicate](first#kotlin.collections%24first(kotlin.Array((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.first(predicate: (T) -> Boolean): T ``` ``` fun ByteArray.first(predicate: (Byte) -> Boolean): Byte ``` ``` fun ShortArray.first(predicate: (Short) -> Boolean): Short ``` ``` fun IntArray.first(predicate: (Int) -> Boolean): Int ``` ``` fun LongArray.first(predicate: (Long) -> Boolean): Long ``` ``` fun FloatArray.first(predicate: (Float) -> Boolean): Float ``` ``` fun DoubleArray.first(predicate: (Double) -> Boolean): Double ``` ``` fun BooleanArray.first(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.first(predicate: (Char) -> Boolean): Char ``` ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` ``` fun UIntArray.first(predicate: (UInt) -> Boolean): UInt ``` ``` fun ULongArray.first(predicate: (ULong) -> Boolean): ULong ``` ``` fun UByteArray.first(predicate: (UByte) -> Boolean): UByte ``` ``` fun UShortArray.first(predicate: (UShort) -> Boolean): UShort ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](first-not-null-of) Returns the first non-null value produced by [transform](first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.Array((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this array in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Array<out T>.firstNotNullOf(     transform: (T) -> R? ): R ``` Returns the first non-null value produced by [transform](first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` Returns the first non-null value produced by [transform](first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Map((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to entries of this map in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOf(     transform: (Entry<K, V>) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](first-not-null-of-or-null) Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.Array((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this array in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Array<out T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Map((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to entries of this map in iteration order, or `null` if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOfOrNull(     transform: (Entry<K, V>) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](first-or-null) Returns the first element, or `null` if the array is empty. ``` fun <T> Array<out T>.firstOrNull(): T? ``` ``` fun ByteArray.firstOrNull(): Byte? ``` ``` fun ShortArray.firstOrNull(): Short? ``` ``` fun IntArray.firstOrNull(): Int? ``` ``` fun LongArray.firstOrNull(): Long? ``` ``` fun FloatArray.firstOrNull(): Float? ``` ``` fun DoubleArray.firstOrNull(): Double? ``` ``` fun BooleanArray.firstOrNull(): Boolean? ``` ``` fun CharArray.firstOrNull(): Char? ``` ``` fun UIntArray.firstOrNull(): UInt? ``` ``` fun ULongArray.firstOrNull(): ULong? ``` ``` fun UByteArray.firstOrNull(): UByte? ``` ``` fun UShortArray.firstOrNull(): UShort? ``` Returns the first element matching the given [predicate](first-or-null#kotlin.collections%24firstOrNull(kotlin.Array((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Array<out T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` ``` fun ByteArray.firstOrNull(     predicate: (Byte) -> Boolean ): Byte? ``` ``` fun ShortArray.firstOrNull(     predicate: (Short) -> Boolean ): Short? ``` ``` fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int? ``` ``` fun LongArray.firstOrNull(     predicate: (Long) -> Boolean ): Long? ``` ``` fun FloatArray.firstOrNull(     predicate: (Float) -> Boolean ): Float? ``` ``` fun DoubleArray.firstOrNull(     predicate: (Double) -> Boolean ): Double? ``` ``` fun BooleanArray.firstOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.firstOrNull(     predicate: (Char) -> Boolean ): Char? ``` ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` ``` fun UIntArray.firstOrNull(     predicate: (UInt) -> Boolean ): UInt? ``` ``` fun ULongArray.firstOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` fun UByteArray.firstOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` fun UShortArray.firstOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element, or `null` if the list is empty. ``` fun <T> List<T>.firstOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](flat-map) Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.collections%24flatMap(kotlin.Array((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <T, R> Array<out T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <R> ByteArray.flatMap(     transform: (Byte) -> Iterable<R> ): List<R> ``` ``` fun <R> ShortArray.flatMap(     transform: (Short) -> Iterable<R> ): List<R> ``` ``` fun <R> IntArray.flatMap(     transform: (Int) -> Iterable<R> ): List<R> ``` ``` fun <R> LongArray.flatMap(     transform: (Long) -> Iterable<R> ): List<R> ``` ``` fun <R> FloatArray.flatMap(     transform: (Float) -> Iterable<R> ): List<R> ``` ``` fun <R> DoubleArray.flatMap(     transform: (Double) -> Iterable<R> ): List<R> ``` ``` fun <R> BooleanArray.flatMap(     transform: (Boolean) -> Iterable<R> ): List<R> ``` ``` fun <R> CharArray.flatMap(     transform: (Char) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Array<out T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` ``` fun <R> UIntArray.flatMap(     transform: (UInt) -> Iterable<R> ): List<R> ``` ``` fun <R> ULongArray.flatMap(     transform: (ULong) -> Iterable<R> ): List<R> ``` ``` fun <R> UByteArray.flatMap(     transform: (UByte) -> Iterable<R> ): List<R> ``` ``` fun <R> UShortArray.flatMap(     transform: (UShort) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Iterable<R> ): List<R> ``` ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](flat-map-indexed) Returns a single list of all elements yielded from results of [transform](flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.Array((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <T, R> Array<out T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <R> ByteArray.flatMapIndexed(     transform: (index: Int, Byte) -> Iterable<R> ): List<R> ``` ``` fun <R> ShortArray.flatMapIndexed(     transform: (index: Int, Short) -> Iterable<R> ): List<R> ``` ``` fun <R> IntArray.flatMapIndexed(     transform: (index: Int, Int) -> Iterable<R> ): List<R> ``` ``` fun <R> LongArray.flatMapIndexed(     transform: (index: Int, Long) -> Iterable<R> ): List<R> ``` ``` fun <R> FloatArray.flatMapIndexed(     transform: (index: Int, Float) -> Iterable<R> ): List<R> ``` ``` fun <R> DoubleArray.flatMapIndexed(     transform: (index: Int, Double) -> Iterable<R> ): List<R> ``` ``` fun <R> BooleanArray.flatMapIndexed(     transform: (index: Int, Boolean) -> Iterable<R> ): List<R> ``` ``` fun <R> CharArray.flatMapIndexed(     transform: (index: Int, Char) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Array<out T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` ``` fun <R> UIntArray.flatMapIndexed(     transform: (index: Int, UInt) -> Iterable<R> ): List<R> ``` ``` fun <R> ULongArray.flatMapIndexed(     transform: (index: Int, ULong) -> Iterable<R> ): List<R> ``` ``` fun <R> UByteArray.flatMapIndexed(     transform: (index: Int, UByte) -> Iterable<R> ): List<R> ``` ``` fun <R> UShortArray.flatMapIndexed(     transform: (index: Int, UShort) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](flat-map-indexed-to) Appends all elements yielded from results of [transform](flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.Array((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original array, to the given [destination](flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.Array((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> ByteArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Byte) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> ShortArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Short) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> IntArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Int) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> LongArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Long) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> FloatArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Float) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> DoubleArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Double) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> BooleanArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Boolean) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> CharArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Char) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> UIntArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, UInt) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> ULongArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, ULong) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> UByteArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, UByte) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> UShortArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, UShort) -> Iterable<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](flat-map-to) Appends all elements yielded from results of [transform](flat-map-to#kotlin.collections%24flatMapTo(kotlin.Array((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original array, to the given [destination](flat-map-to#kotlin.collections%24flatMapTo(kotlin.Array((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> ByteArray.flatMapTo(     destination: C,     transform: (Byte) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> ShortArray.flatMapTo(     destination: C,     transform: (Short) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> IntArray.flatMapTo(     destination: C,     transform: (Int) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> LongArray.flatMapTo(     destination: C,     transform: (Long) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> FloatArray.flatMapTo(     destination: C,     transform: (Float) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> DoubleArray.flatMapTo(     destination: C,     transform: (Double) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> BooleanArray.flatMapTo(     destination: C,     transform: (Boolean) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> CharArray.flatMapTo(     destination: C,     transform: (Char) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> UIntArray.flatMapTo(     destination: C,     transform: (UInt) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> ULongArray.flatMapTo(     destination: C,     transform: (ULong) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> UByteArray.flatMapTo(     destination: C,     transform: (UByte) -> Iterable<R> ): C ``` ``` fun <R, C : MutableCollection<in R>> UShortArray.flatMapTo(     destination: C,     transform: (UShort) -> Iterable<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each entry of original map, to the given [destination](flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Iterable<R> ): C ``` ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <flatten> Returns a single list of all elements from all arrays in the given array. ``` fun <T> Array<out Array<out T>>.flatten(): List<T> ``` Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <fold> Accumulates value starting with [initial](fold#kotlin.collections%24fold(kotlin.Array((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](fold#kotlin.collections%24fold(kotlin.Array((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Array<out T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` ``` fun <R> ByteArray.fold(     initial: R,     operation: (acc: R, Byte) -> R ): R ``` ``` fun <R> ShortArray.fold(     initial: R,     operation: (acc: R, Short) -> R ): R ``` ``` fun <R> IntArray.fold(     initial: R,     operation: (acc: R, Int) -> R ): R ``` ``` fun <R> LongArray.fold(     initial: R,     operation: (acc: R, Long) -> R ): R ``` ``` fun <R> FloatArray.fold(     initial: R,     operation: (acc: R, Float) -> R ): R ``` ``` fun <R> DoubleArray.fold(     initial: R,     operation: (acc: R, Double) -> R ): R ``` ``` fun <R> BooleanArray.fold(     initial: R,     operation: (acc: R, Boolean) -> R ): R ``` ``` fun <R> CharArray.fold(     initial: R,     operation: (acc: R, Char) -> R ): R ``` ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` ``` fun <R> UIntArray.fold(     initial: R,     operation: (acc: R, UInt) -> R ): R ``` ``` fun <R> ULongArray.fold(     initial: R,     operation: (acc: R, ULong) -> R ): R ``` ``` fun <R> UByteArray.fold(     initial: R,     operation: (acc: R, UByte) -> R ): R ``` ``` fun <R> UShortArray.fold(     initial: R,     operation: (acc: R, UShort) -> R ): R ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.Function2((kotlin.collections.fold.K,%20kotlin.collections.fold.T,%20kotlin.collections.fold.R)),%20kotlin.Function3((kotlin.collections.fold.K,%20kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is provided by [initialValueSelector](fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.Function2((kotlin.collections.fold.K,%20kotlin.collections.fold.T,%20kotlin.collections.fold.R)),%20kotlin.Function3((kotlin.collections.fold.K,%20kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initialValueSelector) function. ``` fun <T, K, R> Grouping<T, K>.fold(     initialValueSelector: (key: K, element: T) -> R,     operation: (key: K, accumulator: R, element: T) -> R ): Map<K, R> ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the same [initialValue](fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initialValue) for each group. ``` fun <T, K, R> Grouping<T, K>.fold(     initialValue: R,     operation: (accumulator: R, element: T) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](fold-indexed) Accumulates value starting with [initial](fold-indexed#kotlin.collections%24foldIndexed(kotlin.Array((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](fold-indexed#kotlin.collections%24foldIndexed(kotlin.Array((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <T, R> Array<out T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` ``` fun <R> ByteArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> R ): R ``` ``` fun <R> ShortArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> R ): R ``` ``` fun <R> IntArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> R ): R ``` ``` fun <R> LongArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> R ): R ``` ``` fun <R> FloatArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> R ): R ``` ``` fun <R> DoubleArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> R ): R ``` ``` fun <R> BooleanArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> R ): R ``` ``` fun <R> CharArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): R ``` ``` fun <R> UIntArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> R ): R ``` ``` fun <R> ULongArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): R ``` ``` fun <R> UByteArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> R ): R ``` ``` fun <R> UShortArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UShort) -> R ): R ``` Accumulates value starting with [initial](fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](fold-right) Accumulates value starting with [initial](fold-right#kotlin.collections%24foldRight(kotlin.Array((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](fold-right#kotlin.collections%24foldRight(kotlin.Array((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <T, R> Array<out T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` ``` fun <R> ByteArray.foldRight(     initial: R,     operation: (Byte, acc: R) -> R ): R ``` ``` fun <R> ShortArray.foldRight(     initial: R,     operation: (Short, acc: R) -> R ): R ``` ``` fun <R> IntArray.foldRight(     initial: R,     operation: (Int, acc: R) -> R ): R ``` ``` fun <R> LongArray.foldRight(     initial: R,     operation: (Long, acc: R) -> R ): R ``` ``` fun <R> FloatArray.foldRight(     initial: R,     operation: (Float, acc: R) -> R ): R ``` ``` fun <R> DoubleArray.foldRight(     initial: R,     operation: (Double, acc: R) -> R ): R ``` ``` fun <R> BooleanArray.foldRight(     initial: R,     operation: (Boolean, acc: R) -> R ): R ``` ``` fun <R> CharArray.foldRight(     initial: R,     operation: (Char, acc: R) -> R ): R ``` ``` fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` ``` fun <R> UIntArray.foldRight(     initial: R,     operation: (UInt, acc: R) -> R ): R ``` ``` fun <R> ULongArray.foldRight(     initial: R,     operation: (ULong, acc: R) -> R ): R ``` ``` fun <R> UByteArray.foldRight(     initial: R,     operation: (UByte, acc: R) -> R ): R ``` ``` fun <R> UShortArray.foldRight(     initial: R,     operation: (UShort, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](fold-right-indexed) Accumulates value starting with [initial](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.Array((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.Array((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun <T, R> Array<out T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` ``` fun <R> ByteArray.foldRightIndexed(     initial: R,     operation: (index: Int, Byte, acc: R) -> R ): R ``` ``` fun <R> ShortArray.foldRightIndexed(     initial: R,     operation: (index: Int, Short, acc: R) -> R ): R ``` ``` fun <R> IntArray.foldRightIndexed(     initial: R,     operation: (index: Int, Int, acc: R) -> R ): R ``` ``` fun <R> LongArray.foldRightIndexed(     initial: R,     operation: (index: Int, Long, acc: R) -> R ): R ``` ``` fun <R> FloatArray.foldRightIndexed(     initial: R,     operation: (index: Int, Float, acc: R) -> R ): R ``` ``` fun <R> DoubleArray.foldRightIndexed(     initial: R,     operation: (index: Int, Double, acc: R) -> R ): R ``` ``` fun <R> BooleanArray.foldRightIndexed(     initial: R,     operation: (index: Int, Boolean, acc: R) -> R ): R ``` ``` fun <R> CharArray.foldRightIndexed(     initial: R,     operation: (index: Int, Char, acc: R) -> R ): R ``` ``` fun <R> UIntArray.foldRightIndexed(     initial: R,     operation: (index: Int, UInt, acc: R) -> R ): R ``` ``` fun <R> ULongArray.foldRightIndexed(     initial: R,     operation: (index: Int, ULong, acc: R) -> R ): R ``` ``` fun <R> UByteArray.foldRightIndexed(     initial: R,     operation: (index: Int, UByte, acc: R) -> R ): R ``` ``` fun <R> UShortArray.foldRightIndexed(     initial: R,     operation: (index: Int, UShort, acc: R) -> R ): R ``` Accumulates value starting with [initial](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [foldTo](fold-to) Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map. An initial value of accumulator is provided by [initialValueSelector](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/initialValueSelector) function. ``` fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(     destination: M,     initialValueSelector: (key: K, element: T) -> R,     operation: (key: K, accumulator: R, element: T) -> R ): M ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map. An initial value of accumulator is the same [initialValue](fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/initialValue) for each group. ``` fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(     destination: M,     initialValue: R,     operation: (accumulator: R, element: T) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](for-each) Performs the given [action](for-each#kotlin.collections%24forEach(kotlin.Array((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Array<out T>.forEach(action: (T) -> Unit) ``` ``` fun ByteArray.forEach(action: (Byte) -> Unit) ``` ``` fun ShortArray.forEach(action: (Short) -> Unit) ``` ``` fun IntArray.forEach(action: (Int) -> Unit) ``` ``` fun LongArray.forEach(action: (Long) -> Unit) ``` ``` fun FloatArray.forEach(action: (Float) -> Unit) ``` ``` fun DoubleArray.forEach(action: (Double) -> Unit) ``` ``` fun BooleanArray.forEach(action: (Boolean) -> Unit) ``` ``` fun CharArray.forEach(action: (Char) -> Unit) ``` ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` ``` fun UIntArray.forEach(action: (UInt) -> Unit) ``` ``` fun ULongArray.forEach(action: (ULong) -> Unit) ``` ``` fun UByteArray.forEach(action: (UByte) -> Unit) ``` ``` fun UShortArray.forEach(action: (UShort) -> Unit) ``` Performs the given [action](for-each#kotlin.collections%24forEach(kotlin.collections.Map((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Unit)))/action) on each entry. ``` fun <K, V> Map<out K, V>.forEach(     action: (Entry<K, V>) -> Unit) ``` Performs the given [operation](for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](for-each-indexed) Performs the given [action](for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.Array((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Array<out T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` ``` fun ByteArray.forEachIndexed(     action: (index: Int, Byte) -> Unit) ``` ``` fun ShortArray.forEachIndexed(     action: (index: Int, Short) -> Unit) ``` ``` fun IntArray.forEachIndexed(     action: (index: Int, Int) -> Unit) ``` ``` fun LongArray.forEachIndexed(     action: (index: Int, Long) -> Unit) ``` ``` fun FloatArray.forEachIndexed(     action: (index: Int, Float) -> Unit) ``` ``` fun DoubleArray.forEachIndexed(     action: (index: Int, Double) -> Unit) ``` ``` fun BooleanArray.forEachIndexed(     action: (index: Int, Boolean) -> Unit) ``` ``` fun CharArray.forEachIndexed(     action: (index: Int, Char) -> Unit) ``` ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` ``` fun UIntArray.forEachIndexed(     action: (index: Int, UInt) -> Unit) ``` ``` fun ULongArray.forEachIndexed(     action: (index: Int, ULong) -> Unit) ``` ``` fun UByteArray.forEachIndexed(     action: (index: Int, UByte) -> Unit) ``` ``` fun UShortArray.forEachIndexed(     action: (index: Int, UShort) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the value corresponding to the given [key](get#kotlin.collections%24get(kotlin.collections.Map((kotlin.collections.get.K,%20kotlin.collections.get.V)),%20kotlin.collections.get.K)/key), or `null` if such a key is not present in the map. ``` operator fun <K, V> Map<out K, V>.get(key: K): V? ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [getOrDefault](get-or-default) Returns the value to which the specified key is mapped, or [defaultValue](get-or-default#kotlin.collections%24getOrDefault(kotlin.collections.Map((kotlin.collections.getOrDefault.K,%20kotlin.collections.getOrDefault.V)),%20kotlin.collections.getOrDefault.K,%20kotlin.collections.getOrDefault.V)/defaultValue) if this map contains no mapping for the key. ``` fun <K, V> Map<out K, V>.getOrDefault(     key: K,     defaultValue: V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](get-or-else) Returns an element at the given [index](get-or-else#kotlin.collections%24getOrElse(kotlin.Array((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](get-or-else#kotlin.collections%24getOrElse(kotlin.Array((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](get-or-else#kotlin.collections%24getOrElse(kotlin.Array((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this array. ``` fun <T> Array<out T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` ``` fun ByteArray.getOrElse(     index: Int,     defaultValue: (Int) -> Byte ): Byte ``` ``` fun ShortArray.getOrElse(     index: Int,     defaultValue: (Int) -> Short ): Short ``` ``` fun IntArray.getOrElse(     index: Int,     defaultValue: (Int) -> Int ): Int ``` ``` fun LongArray.getOrElse(     index: Int,     defaultValue: (Int) -> Long ): Long ``` ``` fun FloatArray.getOrElse(     index: Int,     defaultValue: (Int) -> Float ): Float ``` ``` fun DoubleArray.getOrElse(     index: Int,     defaultValue: (Int) -> Double ): Double ``` ``` fun BooleanArray.getOrElse(     index: Int,     defaultValue: (Int) -> Boolean ): Boolean ``` ``` fun CharArray.getOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` ``` fun UIntArray.getOrElse(     index: Int,     defaultValue: (Int) -> UInt ): UInt ``` ``` fun ULongArray.getOrElse(     index: Int,     defaultValue: (Int) -> ULong ): ULong ``` ``` fun UByteArray.getOrElse(     index: Int,     defaultValue: (Int) -> UByte ): UByte ``` ``` fun UShortArray.getOrElse(     index: Int,     defaultValue: (Int) -> UShort ): UShort ``` Returns an element at the given [index](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns the value for the given [key](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/key) if the value is present and not `null`. Otherwise, returns the result of the [defaultValue](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/defaultValue) function. ``` fun <K, V> Map<K, V>.getOrElse(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](get-or-null) Returns an element at the given [index](get-or-null#kotlin.collections%24getOrNull(kotlin.Array((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](get-or-null#kotlin.collections%24getOrNull(kotlin.Array((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this array. ``` fun <T> Array<out T>.getOrNull(index: Int): T? ``` ``` fun ByteArray.getOrNull(index: Int): Byte? ``` ``` fun ShortArray.getOrNull(index: Int): Short? ``` ``` fun IntArray.getOrNull(index: Int): Int? ``` ``` fun LongArray.getOrNull(index: Int): Long? ``` ``` fun FloatArray.getOrNull(index: Int): Float? ``` ``` fun DoubleArray.getOrNull(index: Int): Double? ``` ``` fun BooleanArray.getOrNull(index: Int): Boolean? ``` ``` fun CharArray.getOrNull(index: Int): Char? ``` ``` fun UIntArray.getOrNull(index: Int): UInt? ``` ``` fun ULongArray.getOrNull(index: Int): ULong? ``` ``` fun UByteArray.getOrNull(index: Int): UByte? ``` ``` fun UShortArray.getOrNull(index: Int): UShort? ``` Returns an element at the given [index](get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.getOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrPut](get-or-put) Returns the value for the given [key](get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/key) if the value is present and not `null`. Otherwise, calls the [defaultValue](get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/defaultValue) function, puts its result into the map under the given key and returns the call result. ``` fun <K, V> MutableMap<K, V>.getOrPut(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getValue](get-value) Returns the value of the property for the given object from this read-only map. ``` operator fun <V, V1 : V> Map<in String, V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V1 ``` Returns the value of the property for the given object from this mutable map. ``` operator fun <V, V1 : V> MutableMap<in String, out V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V1 ``` Returns the value for the given [key](get-value#kotlin.collections%24getValue(kotlin.collections.Map((kotlin.collections.getValue.K,%20kotlin.collections.getValue.V)),%20kotlin.collections.getValue.K)/key) or throws an exception if there is no such key in the map. ``` fun <K, V> Map<K, V>.getValue(key: K): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](group-by) Groups elements of the original array by the key returned by the given [keySelector](group-by#kotlin.collections%24groupBy(kotlin.Array((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Array<out T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` ``` fun <K> ByteArray.groupBy(     keySelector: (Byte) -> K ): Map<K, List<Byte>> ``` ``` fun <K> ShortArray.groupBy(     keySelector: (Short) -> K ): Map<K, List<Short>> ``` ``` fun <K> IntArray.groupBy(     keySelector: (Int) -> K ): Map<K, List<Int>> ``` ``` fun <K> LongArray.groupBy(     keySelector: (Long) -> K ): Map<K, List<Long>> ``` ``` fun <K> FloatArray.groupBy(     keySelector: (Float) -> K ): Map<K, List<Float>> ``` ``` fun <K> DoubleArray.groupBy(     keySelector: (Double) -> K ): Map<K, List<Double>> ``` ``` fun <K> BooleanArray.groupBy(     keySelector: (Boolean) -> K ): Map<K, List<Boolean>> ``` ``` fun <K> CharArray.groupBy(     keySelector: (Char) -> K ): Map<K, List<Char>> ``` ``` fun <K> UIntArray.groupBy(     keySelector: (UInt) -> K ): Map<K, List<UInt>> ``` ``` fun <K> ULongArray.groupBy(     keySelector: (ULong) -> K ): Map<K, List<ULong>> ``` ``` fun <K> UByteArray.groupBy(     keySelector: (UByte) -> K ): Map<K, List<UByte>> ``` ``` fun <K> UShortArray.groupBy(     keySelector: (UShort) -> K ): Map<K, List<UShort>> ``` Groups values returned by the [valueTransform](group-by#kotlin.collections%24groupBy(kotlin.Array((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original array by the key returned by the given [keySelector](group-by#kotlin.collections%24groupBy(kotlin.Array((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Array<out T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` ``` fun <K, V> ByteArray.groupBy(     keySelector: (Byte) -> K,     valueTransform: (Byte) -> V ): Map<K, List<V>> ``` ``` fun <K, V> ShortArray.groupBy(     keySelector: (Short) -> K,     valueTransform: (Short) -> V ): Map<K, List<V>> ``` ``` fun <K, V> IntArray.groupBy(     keySelector: (Int) -> K,     valueTransform: (Int) -> V ): Map<K, List<V>> ``` ``` fun <K, V> LongArray.groupBy(     keySelector: (Long) -> K,     valueTransform: (Long) -> V ): Map<K, List<V>> ``` ``` fun <K, V> FloatArray.groupBy(     keySelector: (Float) -> K,     valueTransform: (Float) -> V ): Map<K, List<V>> ``` ``` fun <K, V> DoubleArray.groupBy(     keySelector: (Double) -> K,     valueTransform: (Double) -> V ): Map<K, List<V>> ``` ``` fun <K, V> BooleanArray.groupBy(     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> V ): Map<K, List<V>> ``` ``` fun <K, V> CharArray.groupBy(     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): Map<K, List<V>> ``` ``` fun <K, V> UIntArray.groupBy(     keySelector: (UInt) -> K,     valueTransform: (UInt) -> V ): Map<K, List<V>> ``` ``` fun <K, V> ULongArray.groupBy(     keySelector: (ULong) -> K,     valueTransform: (ULong) -> V ): Map<K, List<V>> ``` ``` fun <K, V> UByteArray.groupBy(     keySelector: (UByte) -> K,     valueTransform: (UByte) -> V ): Map<K, List<V>> ``` ``` fun <K, V> UShortArray.groupBy(     keySelector: (UShort) -> K,     valueTransform: (UShort) -> V ): Map<K, List<V>> ``` Groups elements of the original collection by the key returned by the given [keySelector](group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](group-by-to) Groups elements of the original array by the key returned by the given [keySelector](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Array<out T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<Byte>>> ByteArray.groupByTo(     destination: M,     keySelector: (Byte) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<Short>>> ShortArray.groupByTo(     destination: M,     keySelector: (Short) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<Int>>> IntArray.groupByTo(     destination: M,     keySelector: (Int) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<Long>>> LongArray.groupByTo(     destination: M,     keySelector: (Long) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<Float>>> FloatArray.groupByTo(     destination: M,     keySelector: (Float) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<Double>>> DoubleArray.groupByTo(     destination: M,     keySelector: (Double) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<Boolean>>> BooleanArray.groupByTo(     destination: M,     keySelector: (Boolean) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<Char>>> CharArray.groupByTo(     destination: M,     keySelector: (Char) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<UInt>>> UIntArray.groupByTo(     destination: M,     keySelector: (UInt) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<ULong>>> ULongArray.groupByTo(     destination: M,     keySelector: (ULong) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<UByte>>> UByteArray.groupByTo(     destination: M,     keySelector: (UByte) -> K ): M ``` ``` fun <K, M : MutableMap<in K, MutableList<UShort>>> UShortArray.groupByTo(     destination: M,     keySelector: (UShort) -> K ): M ``` Groups values returned by the [valueTransform](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original array by the key returned by the given [keySelector](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Array<out T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> ByteArray.groupByTo(     destination: M,     keySelector: (Byte) -> K,     valueTransform: (Byte) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> ShortArray.groupByTo(     destination: M,     keySelector: (Short) -> K,     valueTransform: (Short) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> IntArray.groupByTo(     destination: M,     keySelector: (Int) -> K,     valueTransform: (Int) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> LongArray.groupByTo(     destination: M,     keySelector: (Long) -> K,     valueTransform: (Long) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> FloatArray.groupByTo(     destination: M,     keySelector: (Float) -> K,     valueTransform: (Float) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> DoubleArray.groupByTo(     destination: M,     keySelector: (Double) -> K,     valueTransform: (Double) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> BooleanArray.groupByTo(     destination: M,     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> CharArray.groupByTo(     destination: M,     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> UIntArray.groupByTo(     destination: M,     keySelector: (UInt) -> K,     valueTransform: (UInt) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> ULongArray.groupByTo(     destination: M,     keySelector: (ULong) -> K,     valueTransform: (ULong) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> UByteArray.groupByTo(     destination: M,     keySelector: (UByte) -> K,     valueTransform: (UByte) -> V ): M ``` ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> UShortArray.groupByTo(     destination: M,     keySelector: (UShort) -> K,     valueTransform: (UShort) -> V ): M ``` Groups elements of the original collection by the key returned by the given [keySelector](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](grouping-by) Creates a [Grouping](-grouping/index) source from an array to be used later with one of group-and-fold operations using the specified [keySelector](grouping-by#kotlin.collections%24groupingBy(kotlin.Array((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Array<out T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` Creates a [Grouping](-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hashMapOf](hash-map-of) Returns an empty new [HashMap](-hash-map/index#kotlin.collections.HashMap). ``` fun <K, V> hashMapOf(): HashMap<K, V> ``` Returns a new [HashMap](-hash-map/index#kotlin.collections.HashMap) with the specified contents, given as a list of pairs where the first component is the key and the second is the value. ``` fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): HashMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hashSetOf](hash-set-of) Returns an empty new [HashSet](-hash-set/index#kotlin.collections.HashSet). ``` fun <T> hashSetOf(): HashSet<T> ``` Returns a new [HashSet](-hash-set/index#kotlin.collections.HashSet) with the given elements. ``` fun <T> hashSetOf(vararg elements: T): HashSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](if-empty) Returns this array if it's not empty or the result of calling [defaultValue](if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` Returns this map if it's not empty or the result of calling [defaultValue](if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.M,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the map is empty. ``` fun <M, R> M.ifEmpty(     defaultValue: () -> R ): R where M : Map<*, *>, M : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](index-of) Returns first index of [element](index-of#kotlin.collections%24indexOf(kotlin.Array((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the array does not contain element. ``` fun <T> Array<out T>.indexOf(element: T): Int ``` ``` fun ByteArray.indexOf(element: Byte): Int ``` ``` fun ShortArray.indexOf(element: Short): Int ``` ``` fun IntArray.indexOf(element: Int): Int ``` ``` fun LongArray.indexOf(element: Long): Int ``` ``` fun FloatArray.indexOf(element: Float): Int ``` ``` fun DoubleArray.indexOf(element: Double): Int ``` ``` fun BooleanArray.indexOf(element: Boolean): Int ``` ``` fun CharArray.indexOf(element: Char): Int ``` ``` fun UIntArray.indexOf(element: UInt): Int ``` ``` fun ULongArray.indexOf(element: ULong): Int ``` ``` fun UByteArray.indexOf(element: UByte): Int ``` ``` fun UShortArray.indexOf(element: UShort): Int ``` Returns first index of [element](index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` Returns first index of [element](index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](index-of-first) Returns index of the first element matching the given [predicate](index-of-first#kotlin.collections%24indexOfFirst(kotlin.Array((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun <T> Array<out T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` ``` fun ByteArray.indexOfFirst(predicate: (Byte) -> Boolean): Int ``` ``` fun ShortArray.indexOfFirst(     predicate: (Short) -> Boolean ): Int ``` ``` fun IntArray.indexOfFirst(predicate: (Int) -> Boolean): Int ``` ``` fun LongArray.indexOfFirst(predicate: (Long) -> Boolean): Int ``` ``` fun FloatArray.indexOfFirst(     predicate: (Float) -> Boolean ): Int ``` ``` fun DoubleArray.indexOfFirst(     predicate: (Double) -> Boolean ): Int ``` ``` fun BooleanArray.indexOfFirst(     predicate: (Boolean) -> Boolean ): Int ``` ``` fun CharArray.indexOfFirst(predicate: (Char) -> Boolean): Int ``` ``` fun UIntArray.indexOfFirst(predicate: (UInt) -> Boolean): Int ``` ``` fun ULongArray.indexOfFirst(     predicate: (ULong) -> Boolean ): Int ``` ``` fun UByteArray.indexOfFirst(     predicate: (UByte) -> Boolean ): Int ``` ``` fun UShortArray.indexOfFirst(     predicate: (UShort) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](index-of-last) Returns index of the last element matching the given [predicate](index-of-last#kotlin.collections%24indexOfLast(kotlin.Array((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun <T> Array<out T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` ``` fun ByteArray.indexOfLast(predicate: (Byte) -> Boolean): Int ``` ``` fun ShortArray.indexOfLast(     predicate: (Short) -> Boolean ): Int ``` ``` fun IntArray.indexOfLast(predicate: (Int) -> Boolean): Int ``` ``` fun LongArray.indexOfLast(predicate: (Long) -> Boolean): Int ``` ``` fun FloatArray.indexOfLast(     predicate: (Float) -> Boolean ): Int ``` ``` fun DoubleArray.indexOfLast(     predicate: (Double) -> Boolean ): Int ``` ``` fun BooleanArray.indexOfLast(     predicate: (Boolean) -> Boolean ): Int ``` ``` fun CharArray.indexOfLast(predicate: (Char) -> Boolean): Int ``` ``` fun UIntArray.indexOfLast(predicate: (UInt) -> Boolean): Int ``` ``` fun ULongArray.indexOfLast(     predicate: (ULong) -> Boolean ): Int ``` ``` fun UByteArray.indexOfLast(     predicate: (UByte) -> Boolean ): Int ``` ``` fun UShortArray.indexOfLast(     predicate: (UShort) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <intersect> Returns a set containing all elements that are contained by both this array and the specified collection. ``` infix fun <T> any_array<T>.intersect(     other: Iterable<T> ): Set<T> ``` Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Returns `true` if the array is empty. ``` fun <T> any_array<T>.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](is-not-empty) Returns `true` if the array is not empty. ``` fun <T> any_array<T>.isNotEmpty(): Boolean ``` Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` Returns `true` if this map is not empty. ``` fun <K, V> Map<out K, V>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](is-null-or-empty) Returns `true` if this nullable array is either null or empty. ``` fun Array<*>?.isNullOrEmpty(): Boolean ``` Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` Returns `true` if this nullable map is either null or empty. ``` fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Iterable](-iterable) Given an [iterator](-iterable#kotlin.collections%24Iterable(kotlin.Function0((kotlin.collections.Iterator((kotlin.collections.Iterable.T)))))/iterator) function constructs an [Iterable](-iterable/index#kotlin.collections.Iterable) instance that returns values through the [Iterator](-iterator/index#kotlin.collections.Iterator) provided by that function. ``` fun <T> Iterable(iterator: () -> Iterator<T>): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` Returns an [Iterator](-iterator/index#kotlin.collections.Iterator) over the entries in the [Map](-map/index#kotlin.collections.Map). ``` operator fun <K, V> Map<out K, V>.iterator(): Iterator<Entry<K, V>> ``` Returns a [MutableIterator](-mutable-iterator/index#kotlin.collections.MutableIterator) over the mutable entries in the [MutableMap](-mutable-map/index#kotlin.collections.MutableMap). ``` operator fun <K, V> MutableMap<K, V>.iterator(): MutableIterator<MutableEntry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](join-to) Appends the string from all the elements separated using [separator](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](join-to#kotlin.collections%24joinTo(kotlin.Array((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Array<out T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> ByteArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Byte) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> ShortArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Short) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> IntArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Int) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> LongArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Long) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> FloatArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Float) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> DoubleArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Double) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> BooleanArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Boolean) -> CharSequence)? = null ): A ``` ``` fun <A : Appendable> CharArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Char) -> CharSequence)? = null ): A ``` ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](join-to-string) Creates a string from all the elements separated using [separator](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Array<out T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` ``` fun ByteArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Byte) -> CharSequence)? = null ): String ``` ``` fun ShortArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Short) -> CharSequence)? = null ): String ``` ``` fun IntArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Int) -> CharSequence)? = null ): String ``` ``` fun LongArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Long) -> CharSequence)? = null ): String ``` ``` fun FloatArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Float) -> CharSequence)? = null ): String ``` ``` fun DoubleArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Double) -> CharSequence)? = null ): String ``` ``` fun BooleanArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Boolean) -> CharSequence)? = null ): String ``` ``` fun CharArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Char) -> CharSequence)? = null ): String ``` ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> Returns the last element. ``` fun <T> Array<out T>.last(): T ``` ``` fun ByteArray.last(): Byte ``` ``` fun ShortArray.last(): Short ``` ``` fun IntArray.last(): Int ``` ``` fun LongArray.last(): Long ``` ``` fun FloatArray.last(): Float ``` ``` fun DoubleArray.last(): Double ``` ``` fun BooleanArray.last(): Boolean ``` ``` fun CharArray.last(): Char ``` ``` fun <T> Iterable<T>.last(): T ``` ``` fun <T> List<T>.last(): T ``` ``` fun UIntArray.last(): UInt ``` ``` fun ULongArray.last(): ULong ``` ``` fun UByteArray.last(): UByte ``` ``` fun UShortArray.last(): UShort ``` Returns the last element matching the given [predicate](last#kotlin.collections%24last(kotlin.Array((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.last(predicate: (T) -> Boolean): T ``` ``` fun ByteArray.last(predicate: (Byte) -> Boolean): Byte ``` ``` fun ShortArray.last(predicate: (Short) -> Boolean): Short ``` ``` fun IntArray.last(predicate: (Int) -> Boolean): Int ``` ``` fun LongArray.last(predicate: (Long) -> Boolean): Long ``` ``` fun FloatArray.last(predicate: (Float) -> Boolean): Float ``` ``` fun DoubleArray.last(predicate: (Double) -> Boolean): Double ``` ``` fun BooleanArray.last(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.last(predicate: (Char) -> Boolean): Char ``` ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` ``` fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` ``` fun UIntArray.last(predicate: (UInt) -> Boolean): UInt ``` ``` fun ULongArray.last(predicate: (ULong) -> Boolean): ULong ``` ``` fun UByteArray.last(predicate: (UByte) -> Boolean): UByte ``` ``` fun UShortArray.last(predicate: (UShort) -> Boolean): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](last-index-of) Returns last index of [element](last-index-of#kotlin.collections%24lastIndexOf(kotlin.Array((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the array does not contain element. ``` fun <T> Array<out T>.lastIndexOf(element: T): Int ``` ``` fun ByteArray.lastIndexOf(element: Byte): Int ``` ``` fun ShortArray.lastIndexOf(element: Short): Int ``` ``` fun IntArray.lastIndexOf(element: Int): Int ``` ``` fun LongArray.lastIndexOf(element: Long): Int ``` ``` fun FloatArray.lastIndexOf(element: Float): Int ``` ``` fun DoubleArray.lastIndexOf(element: Double): Int ``` ``` fun BooleanArray.lastIndexOf(element: Boolean): Int ``` ``` fun CharArray.lastIndexOf(element: Char): Int ``` ``` fun UIntArray.lastIndexOf(element: UInt): Int ``` ``` fun ULongArray.lastIndexOf(element: ULong): Int ``` ``` fun UByteArray.lastIndexOf(element: UByte): Int ``` ``` fun UShortArray.lastIndexOf(element: UShort): Int ``` Returns last index of [element](last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](last-or-null) Returns the last element, or `null` if the array is empty. ``` fun <T> Array<out T>.lastOrNull(): T? ``` ``` fun ByteArray.lastOrNull(): Byte? ``` ``` fun ShortArray.lastOrNull(): Short? ``` ``` fun IntArray.lastOrNull(): Int? ``` ``` fun LongArray.lastOrNull(): Long? ``` ``` fun FloatArray.lastOrNull(): Float? ``` ``` fun DoubleArray.lastOrNull(): Double? ``` ``` fun BooleanArray.lastOrNull(): Boolean? ``` ``` fun CharArray.lastOrNull(): Char? ``` ``` fun UIntArray.lastOrNull(): UInt? ``` ``` fun ULongArray.lastOrNull(): ULong? ``` ``` fun UByteArray.lastOrNull(): UByte? ``` ``` fun UShortArray.lastOrNull(): UShort? ``` Returns the last element matching the given [predicate](last-or-null#kotlin.collections%24lastOrNull(kotlin.Array((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Array<out T>.lastOrNull(     predicate: (T) -> Boolean ): T? ``` ``` fun ByteArray.lastOrNull(predicate: (Byte) -> Boolean): Byte? ``` ``` fun ShortArray.lastOrNull(     predicate: (Short) -> Boolean ): Short? ``` ``` fun IntArray.lastOrNull(predicate: (Int) -> Boolean): Int? ``` ``` fun LongArray.lastOrNull(predicate: (Long) -> Boolean): Long? ``` ``` fun FloatArray.lastOrNull(     predicate: (Float) -> Boolean ): Float? ``` ``` fun DoubleArray.lastOrNull(     predicate: (Double) -> Boolean ): Double? ``` ``` fun BooleanArray.lastOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.lastOrNull(predicate: (Char) -> Boolean): Char? ``` ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun UIntArray.lastOrNull(predicate: (UInt) -> Boolean): UInt? ``` ``` fun ULongArray.lastOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` fun UByteArray.lastOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` fun UShortArray.lastOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element, or `null` if the list is empty. ``` fun <T> List<T>.lastOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [linkedMapOf](linked-map-of) Returns an empty new [LinkedHashMap](-linked-hash-map/index#kotlin.collections.LinkedHashMap). ``` fun <K, V> linkedMapOf(): LinkedHashMap<K, V> ``` Returns a new [LinkedHashMap](-linked-hash-map/index#kotlin.collections.LinkedHashMap) with the specified contents, given as a list of pairs where the first component is the key and the second is the value. ``` fun <K, V> linkedMapOf(     vararg pairs: Pair<K, V> ): LinkedHashMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [linkedSetOf](linked-set-of) Returns an empty new [LinkedHashSet](-linked-hash-set/index#kotlin.collections.LinkedHashSet). ``` fun <T> linkedSetOf(): LinkedHashSet<T> ``` Returns a new [LinkedHashSet](-linked-hash-set/index#kotlin.collections.LinkedHashSet) with the given elements. Elements of the set are iterated in the order they were specified. ``` fun <T> linkedSetOf(vararg elements: T): LinkedHashSet<T> ``` **Platform and version requirements:** JS (1.1) #### [linkedStringMapOf](linked-string-map-of) Constructs the specialized implementation of [LinkedHashMap](-linked-hash-map/index#kotlin.collections.LinkedHashMap) with String keys, which stores the keys as properties of JS object without hashing them. ``` fun <V> linkedStringMapOf(     vararg pairs: Pair<String, V> ): LinkedHashMap<String, V> ``` **Platform and version requirements:** JS (1.1) #### [linkedStringSetOf](linked-string-set-of) Creates a new instance of the specialized implementation of [LinkedHashSet](-linked-hash-set/index#kotlin.collections.LinkedHashSet) with the specified String elements, which elements the keys as properties of JS object without hashing them. ``` fun linkedStringSetOf(     vararg elements: String ): LinkedHashSet<String> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [List](-list) Creates a new read-only list with the specified [size](-list#kotlin.collections%24List(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.List.T)))/size), where each element is calculated by calling the specified [init](-list#kotlin.collections%24List(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.List.T)))/init) function. ``` fun <T> List(size: Int, init: (index: Int) -> T): List<T> ``` #### [listOf](list-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a new read-only list of given elements. The returned list is serializable (JVM). ``` fun <T> listOf(vararg elements: T): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns an empty read-only list. The returned list is serializable (JVM). ``` fun <T> listOf(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1) Returns an immutable list containing only the specified object [element](list-of#kotlin.collections%24listOf(kotlin.collections.listOf.T)/element). The returned list is serializable. ``` fun <T> listOf(element: T): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [listOfNotNull](list-of-not-null) Returns a new read-only list either of single given element, if it is not null, or empty list if the element is null. The returned list is serializable (JVM). ``` fun <T : Any> listOfNotNull(element: T?): List<T> ``` Returns a new read-only list only of those given elements, that are not null. The returned list is serializable (JVM). ``` fun <T : Any> listOfNotNull(vararg elements: T?): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <map> Returns a list containing the results of applying the given [transform](map#kotlin.collections%24map(kotlin.Array((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <T, R> Array<out T>.map(transform: (T) -> R): List<R> ``` ``` fun <R> ByteArray.map(transform: (Byte) -> R): List<R> ``` ``` fun <R> ShortArray.map(transform: (Short) -> R): List<R> ``` ``` fun <R> IntArray.map(transform: (Int) -> R): List<R> ``` ``` fun <R> LongArray.map(transform: (Long) -> R): List<R> ``` ``` fun <R> FloatArray.map(transform: (Float) -> R): List<R> ``` ``` fun <R> DoubleArray.map(transform: (Double) -> R): List<R> ``` ``` fun <R> BooleanArray.map(transform: (Boolean) -> R): List<R> ``` ``` fun <R> CharArray.map(transform: (Char) -> R): List<R> ``` ``` fun <R> UIntArray.map(transform: (UInt) -> R): List<R> ``` ``` fun <R> ULongArray.map(transform: (ULong) -> R): List<R> ``` ``` fun <R> UByteArray.map(transform: (UByte) -> R): List<R> ``` ``` fun <R> UShortArray.map(transform: (UShort) -> R): List<R> ``` Returns a list containing the results of applying the given [transform](map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` Returns a list containing the results of applying the given [transform](map#kotlin.collections%24map(kotlin.collections.Map((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.collections.map.R)))/transform) function to each entry in the original map. ``` fun <K, V, R> Map<out K, V>.map(     transform: (Entry<K, V>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](map-indexed) Returns a list containing the results of applying the given [transform](map-indexed#kotlin.collections%24mapIndexed(kotlin.Array((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <T, R> Array<out T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` ``` fun <R> ByteArray.mapIndexed(     transform: (index: Int, Byte) -> R ): List<R> ``` ``` fun <R> ShortArray.mapIndexed(     transform: (index: Int, Short) -> R ): List<R> ``` ``` fun <R> IntArray.mapIndexed(     transform: (index: Int, Int) -> R ): List<R> ``` ``` fun <R> LongArray.mapIndexed(     transform: (index: Int, Long) -> R ): List<R> ``` ``` fun <R> FloatArray.mapIndexed(     transform: (index: Int, Float) -> R ): List<R> ``` ``` fun <R> DoubleArray.mapIndexed(     transform: (index: Int, Double) -> R ): List<R> ``` ``` fun <R> BooleanArray.mapIndexed(     transform: (index: Int, Boolean) -> R ): List<R> ``` ``` fun <R> CharArray.mapIndexed(     transform: (index: Int, Char) -> R ): List<R> ``` ``` fun <R> UIntArray.mapIndexed(     transform: (index: Int, UInt) -> R ): List<R> ``` ``` fun <R> ULongArray.mapIndexed(     transform: (index: Int, ULong) -> R ): List<R> ``` ``` fun <R> UByteArray.mapIndexed(     transform: (index: Int, UByte) -> R ): List<R> ``` ``` fun <R> UShortArray.mapIndexed(     transform: (index: Int, UShort) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.Array((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original array. ``` fun <T, R : Any> Array<out T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](map-indexed-not-null-to) Applies the given [transform](map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.Array((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original array and appends only the non-null results to the given [destination](map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.Array((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Array<out T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` Applies the given [transform](map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](map-indexed-to) Applies the given [transform](map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.Array((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original array and appends the results to the given [destination](map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.Array((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Array<out T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> ByteArray.mapIndexedTo(     destination: C,     transform: (index: Int, Byte) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> ShortArray.mapIndexedTo(     destination: C,     transform: (index: Int, Short) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> IntArray.mapIndexedTo(     destination: C,     transform: (index: Int, Int) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> LongArray.mapIndexedTo(     destination: C,     transform: (index: Int, Long) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> FloatArray.mapIndexedTo(     destination: C,     transform: (index: Int, Float) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> DoubleArray.mapIndexedTo(     destination: C,     transform: (index: Int, Double) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> BooleanArray.mapIndexedTo(     destination: C,     transform: (index: Int, Boolean) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> CharArray.mapIndexedTo(     destination: C,     transform: (index: Int, Char) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> UIntArray.mapIndexedTo(     destination: C,     transform: (index: Int, UInt) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> ULongArray.mapIndexedTo(     destination: C,     transform: (index: Int, ULong) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> UByteArray.mapIndexedTo(     destination: C,     transform: (index: Int, UByte) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> UShortArray.mapIndexedTo(     destination: C,     transform: (index: Int, UShort) -> R ): C ``` Applies the given [transform](map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeys](map-keys) Returns a new Map with entries having the keys obtained by applying the [transform](map-keys#kotlin.collections%24mapKeys(kotlin.collections.Map((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.collections.mapKeys.R)))/transform) function to each entry in this [Map](-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R> Map<out K, V>.mapKeys(     transform: (Entry<K, V>) -> R ): Map<R, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeysTo](map-keys-to) Populates the given [destination](map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/destination) map with entries having the keys obtained by applying the [transform](map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/transform) function to each entry in this [Map](-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](map-not-null) Returns a list containing only the non-null results of applying the given [transform](map-not-null#kotlin.collections%24mapNotNull(kotlin.Array((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original array. ``` fun <T, R : Any> Array<out T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Map((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.collections.mapNotNull.R?)))/transform) function to each entry in the original map. ``` fun <K, V, R : Any> Map<out K, V>.mapNotNull(     transform: (Entry<K, V>) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](map-not-null-to) Applies the given [transform](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.Array((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original array and appends only the non-null results to the given [destination](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.Array((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Array<out T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` Applies the given [transform](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` Applies the given [transform](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each entry in the original map and appends only the non-null results to the given [destination](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(     destination: C,     transform: (Entry<K, V>) -> R? ): C ``` #### [mapOf](map-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a new read-only map with the specified contents, given as a list of pairs where the first value is the key and the second is the value. ``` fun <K, V> mapOf(vararg pairs: Pair<K, V>): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns an empty read-only map. ``` fun <K, V> mapOf(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.1) Returns an immutable map, mapping only the specified key to the specified value. ``` fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](map-to) Applies the given [transform](map-to#kotlin.collections%24mapTo(kotlin.Array((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original array and appends the results to the given [destination](map-to#kotlin.collections%24mapTo(kotlin.Array((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Array<out T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> ByteArray.mapTo(     destination: C,     transform: (Byte) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> ShortArray.mapTo(     destination: C,     transform: (Short) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> IntArray.mapTo(     destination: C,     transform: (Int) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> LongArray.mapTo(     destination: C,     transform: (Long) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> FloatArray.mapTo(     destination: C,     transform: (Float) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> DoubleArray.mapTo(     destination: C,     transform: (Double) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> BooleanArray.mapTo(     destination: C,     transform: (Boolean) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> CharArray.mapTo(     destination: C,     transform: (Char) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> UIntArray.mapTo(     destination: C,     transform: (UInt) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> ULongArray.mapTo(     destination: C,     transform: (ULong) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> UByteArray.mapTo(     destination: C,     transform: (UByte) -> R ): C ``` ``` fun <R, C : MutableCollection<in R>> UShortArray.mapTo(     destination: C,     transform: (UShort) -> R ): C ``` Applies the given [transform](map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` Applies the given [transform](map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/transform) function to each entry of the original map and appends the results to the given [destination](map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(     destination: C,     transform: (Entry<K, V>) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValues](map-values) Returns a new map with entries having the keys of this map and the values obtained by applying the [transform](map-values#kotlin.collections%24mapValues(kotlin.collections.Map((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.collections.mapValues.R)))/transform) function to each entry in this [Map](-map/index#kotlin.collections.Map). ``` fun <K, V, R> Map<out K, V>.mapValues(     transform: (Entry<K, V>) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValuesTo](map-values-to) Populates the given [destination](map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/destination) map with entries having the keys of this map and the values obtained by applying the [transform](map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/transform) function to each entry in this [Map](-map/index#kotlin.collections.Map). ``` fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` #### <max> Returns the largest element. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Array<out Double>.max(): Double ``` **Platform and version requirements:** JVM (1.1) ``` fun Array<out Double>.max(): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Array<out Float>.max(): Float ``` **Platform and version requirements:** JVM (1.1) ``` fun Array<out Float>.max(): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T : Comparable<T>> Array<out T>.max(): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T : Comparable<T>> Array<out T>.max(): T? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun ByteArray.max(): Byte ``` **Platform and version requirements:** JVM (1.0) ``` fun ByteArray.max(): Byte? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun ShortArray.max(): Short ``` **Platform and version requirements:** JVM (1.0) ``` fun ShortArray.max(): Short? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun IntArray.max(): Int ``` **Platform and version requirements:** JVM (1.0) ``` fun IntArray.max(): Int? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun LongArray.max(): Long ``` **Platform and version requirements:** JVM (1.0) ``` fun LongArray.max(): Long? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun FloatArray.max(): Float ``` **Platform and version requirements:** JVM (1.0) ``` fun FloatArray.max(): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun DoubleArray.max(): Double ``` **Platform and version requirements:** JVM (1.0) ``` fun DoubleArray.max(): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun CharArray.max(): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun CharArray.max(): Char? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Iterable<Double>.max(): Double ``` **Platform and version requirements:** JVM (1.1) ``` fun Iterable<Double>.max(): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Iterable<Float>.max(): Float ``` **Platform and version requirements:** JVM (1.1) ``` fun Iterable<Float>.max(): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T : Comparable<T>> Iterable<T>.max(): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T : Comparable<T>> Iterable<T>.max(): T? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun UIntArray.max(): UInt ``` **Platform and version requirements:** JVM (1.3) ``` fun UIntArray.max(): UInt? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun ULongArray.max(): ULong ``` **Platform and version requirements:** JVM (1.3) ``` fun ULongArray.max(): ULong? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun UByteArray.max(): UByte ``` **Platform and version requirements:** JVM (1.3) ``` fun UByteArray.max(): UByte? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun UShortArray.max(): UShort ``` **Platform and version requirements:** JVM (1.3) ``` fun UShortArray.max(): UShort? ``` #### [maxBy](max-by) Returns the first element yielding the largest value of the given function. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T, R : Comparable<R>> Array<out T>.maxBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T, R : Comparable<R>> Array<out T>.maxBy(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> ByteArray.maxBy(     selector: (Byte) -> R ): Byte ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> ByteArray.maxBy(     selector: (Byte) -> R ): Byte? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> ShortArray.maxBy(     selector: (Short) -> R ): Short ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> ShortArray.maxBy(     selector: (Short) -> R ): Short? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> IntArray.maxBy(     selector: (Int) -> R ): Int ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> IntArray.maxBy(     selector: (Int) -> R ): Int? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> LongArray.maxBy(     selector: (Long) -> R ): Long ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> LongArray.maxBy(     selector: (Long) -> R ): Long? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> FloatArray.maxBy(     selector: (Float) -> R ): Float ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> FloatArray.maxBy(     selector: (Float) -> R ): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> DoubleArray.maxBy(     selector: (Double) -> R ): Double ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> DoubleArray.maxBy(     selector: (Double) -> R ): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> BooleanArray.maxBy(     selector: (Boolean) -> R ): Boolean ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> BooleanArray.maxBy(     selector: (Boolean) -> R ): Boolean? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> CharArray.maxBy(     selector: (Char) -> R ): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> CharArray.maxBy(     selector: (Char) -> R ): Char? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T, R : Comparable<R>> Iterable<T>.maxBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T, R : Comparable<R>> Iterable<T>.maxBy(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> UIntArray.maxBy(     selector: (UInt) -> R ): UInt ``` **Platform and version requirements:** JVM (1.3) ``` fun <R : Comparable<R>> UIntArray.maxBy(     selector: (UInt) -> R ): UInt? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> ULongArray.maxBy(     selector: (ULong) -> R ): ULong ``` **Platform and version requirements:** JVM (1.3) ``` fun <R : Comparable<R>> ULongArray.maxBy(     selector: (ULong) -> R ): ULong? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> UByteArray.maxBy(     selector: (UByte) -> R ): UByte ``` **Platform and version requirements:** JVM (1.3) ``` fun <R : Comparable<R>> UByteArray.maxBy(     selector: (UByte) -> R ): UByte? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> UShortArray.maxBy(     selector: (UShort) -> R ): UShort ``` **Platform and version requirements:** JVM (1.3) ``` fun <R : Comparable<R>> UShortArray.maxBy(     selector: (UShort) -> R ): UShort? ``` Returns the first entry yielding the largest value of the given function. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(     selector: (Entry<K, V>) -> R ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Array<out T>.maxByOrNull(     selector: (T) -> R ): T? ``` ``` fun <R : Comparable<R>> ByteArray.maxByOrNull(     selector: (Byte) -> R ): Byte? ``` ``` fun <R : Comparable<R>> ShortArray.maxByOrNull(     selector: (Short) -> R ): Short? ``` ``` fun <R : Comparable<R>> IntArray.maxByOrNull(     selector: (Int) -> R ): Int? ``` ``` fun <R : Comparable<R>> LongArray.maxByOrNull(     selector: (Long) -> R ): Long? ``` ``` fun <R : Comparable<R>> FloatArray.maxByOrNull(     selector: (Float) -> R ): Float? ``` ``` fun <R : Comparable<R>> DoubleArray.maxByOrNull(     selector: (Double) -> R ): Double? ``` ``` fun <R : Comparable<R>> BooleanArray.maxByOrNull(     selector: (Boolean) -> R ): Boolean? ``` ``` fun <R : Comparable<R>> CharArray.maxByOrNull(     selector: (Char) -> R ): Char? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` ``` fun <R : Comparable<R>> UIntArray.maxByOrNull(     selector: (UInt) -> R ): UInt? ``` ``` fun <R : Comparable<R>> ULongArray.maxByOrNull(     selector: (ULong) -> R ): ULong? ``` ``` fun <R : Comparable<R>> UByteArray.maxByOrNull(     selector: (UByte) -> R ): UByte? ``` ``` fun <R : Comparable<R>> UShortArray.maxByOrNull(     selector: (UShort) -> R ): UShort? ``` Returns the first entry yielding the largest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](max-of) Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.Array((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <T> Array<out T>.maxOf(selector: (T) -> Double): Double ``` ``` fun ByteArray.maxOf(selector: (Byte) -> Double): Double ``` ``` fun ShortArray.maxOf(selector: (Short) -> Double): Double ``` ``` fun IntArray.maxOf(selector: (Int) -> Double): Double ``` ``` fun LongArray.maxOf(selector: (Long) -> Double): Double ``` ``` fun FloatArray.maxOf(selector: (Float) -> Double): Double ``` ``` fun DoubleArray.maxOf(selector: (Double) -> Double): Double ``` ``` fun BooleanArray.maxOf(selector: (Boolean) -> Double): Double ``` ``` fun CharArray.maxOf(selector: (Char) -> Double): Double ``` ``` fun <T> Array<out T>.maxOf(selector: (T) -> Float): Float ``` ``` fun ByteArray.maxOf(selector: (Byte) -> Float): Float ``` ``` fun ShortArray.maxOf(selector: (Short) -> Float): Float ``` ``` fun IntArray.maxOf(selector: (Int) -> Float): Float ``` ``` fun LongArray.maxOf(selector: (Long) -> Float): Float ``` ``` fun FloatArray.maxOf(selector: (Float) -> Float): Float ``` ``` fun DoubleArray.maxOf(selector: (Double) -> Float): Float ``` ``` fun BooleanArray.maxOf(selector: (Boolean) -> Float): Float ``` ``` fun CharArray.maxOf(selector: (Char) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Array<out T>.maxOf(     selector: (T) -> R ): R ``` ``` fun <R : Comparable<R>> ByteArray.maxOf(     selector: (Byte) -> R ): R ``` ``` fun <R : Comparable<R>> ShortArray.maxOf(     selector: (Short) -> R ): R ``` ``` fun <R : Comparable<R>> IntArray.maxOf(     selector: (Int) -> R ): R ``` ``` fun <R : Comparable<R>> LongArray.maxOf(     selector: (Long) -> R ): R ``` ``` fun <R : Comparable<R>> FloatArray.maxOf(     selector: (Float) -> R ): R ``` ``` fun <R : Comparable<R>> DoubleArray.maxOf(     selector: (Double) -> R ): R ``` ``` fun <R : Comparable<R>> BooleanArray.maxOf(     selector: (Boolean) -> R ): R ``` ``` fun <R : Comparable<R>> CharArray.maxOf(     selector: (Char) -> R ): R ``` ``` fun UIntArray.maxOf(selector: (UInt) -> Double): Double ``` ``` fun ULongArray.maxOf(selector: (ULong) -> Double): Double ``` ``` fun UByteArray.maxOf(selector: (UByte) -> Double): Double ``` ``` fun UShortArray.maxOf(selector: (UShort) -> Double): Double ``` ``` fun UIntArray.maxOf(selector: (UInt) -> Float): Float ``` ``` fun ULongArray.maxOf(selector: (ULong) -> Float): Float ``` ``` fun UByteArray.maxOf(selector: (UByte) -> Float): Float ``` ``` fun UShortArray.maxOf(selector: (UShort) -> Float): Float ``` ``` fun <R : Comparable<R>> UIntArray.maxOf(     selector: (UInt) -> R ): R ``` ``` fun <R : Comparable<R>> ULongArray.maxOf(     selector: (ULong) -> R ): R ``` ``` fun <R : Comparable<R>> UByteArray.maxOf(     selector: (UByte) -> R ): R ``` ``` fun <R : Comparable<R>> UShortArray.maxOf(     selector: (UShort) -> R ): R ``` Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](max-of-or-null) Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.Array((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <T> Array<out T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun ByteArray.maxOfOrNull(     selector: (Byte) -> Double ): Double? ``` ``` fun ShortArray.maxOfOrNull(     selector: (Short) -> Double ): Double? ``` ``` fun IntArray.maxOfOrNull(selector: (Int) -> Double): Double? ``` ``` fun LongArray.maxOfOrNull(     selector: (Long) -> Double ): Double? ``` ``` fun FloatArray.maxOfOrNull(     selector: (Float) -> Double ): Double? ``` ``` fun DoubleArray.maxOfOrNull(     selector: (Double) -> Double ): Double? ``` ``` fun BooleanArray.maxOfOrNull(     selector: (Boolean) -> Double ): Double? ``` ``` fun CharArray.maxOfOrNull(     selector: (Char) -> Double ): Double? ``` ``` fun <T> Array<out T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun ByteArray.maxOfOrNull(selector: (Byte) -> Float): Float? ``` ``` fun ShortArray.maxOfOrNull(     selector: (Short) -> Float ): Float? ``` ``` fun IntArray.maxOfOrNull(selector: (Int) -> Float): Float? ``` ``` fun LongArray.maxOfOrNull(selector: (Long) -> Float): Float? ``` ``` fun FloatArray.maxOfOrNull(     selector: (Float) -> Float ): Float? ``` ``` fun DoubleArray.maxOfOrNull(     selector: (Double) -> Float ): Float? ``` ``` fun BooleanArray.maxOfOrNull(     selector: (Boolean) -> Float ): Float? ``` ``` fun CharArray.maxOfOrNull(selector: (Char) -> Float): Float? ``` ``` fun <T, R : Comparable<R>> Array<out T>.maxOfOrNull(     selector: (T) -> R ): R? ``` ``` fun <R : Comparable<R>> ByteArray.maxOfOrNull(     selector: (Byte) -> R ): R? ``` ``` fun <R : Comparable<R>> ShortArray.maxOfOrNull(     selector: (Short) -> R ): R? ``` ``` fun <R : Comparable<R>> IntArray.maxOfOrNull(     selector: (Int) -> R ): R? ``` ``` fun <R : Comparable<R>> LongArray.maxOfOrNull(     selector: (Long) -> R ): R? ``` ``` fun <R : Comparable<R>> FloatArray.maxOfOrNull(     selector: (Float) -> R ): R? ``` ``` fun <R : Comparable<R>> DoubleArray.maxOfOrNull(     selector: (Double) -> R ): R? ``` ``` fun <R : Comparable<R>> BooleanArray.maxOfOrNull(     selector: (Boolean) -> R ): R? ``` ``` fun <R : Comparable<R>> CharArray.maxOfOrNull(     selector: (Char) -> R ): R? ``` ``` fun UIntArray.maxOfOrNull(     selector: (UInt) -> Double ): Double? ``` ``` fun ULongArray.maxOfOrNull(     selector: (ULong) -> Double ): Double? ``` ``` fun UByteArray.maxOfOrNull(     selector: (UByte) -> Double ): Double? ``` ``` fun UShortArray.maxOfOrNull(     selector: (UShort) -> Double ): Double? ``` ``` fun UIntArray.maxOfOrNull(selector: (UInt) -> Float): Float? ``` ``` fun ULongArray.maxOfOrNull(     selector: (ULong) -> Float ): Float? ``` ``` fun UByteArray.maxOfOrNull(     selector: (UByte) -> Float ): Float? ``` ``` fun UShortArray.maxOfOrNull(     selector: (UShort) -> Float ): Float? ``` ``` fun <R : Comparable<R>> UIntArray.maxOfOrNull(     selector: (UInt) -> R ): R? ``` ``` fun <R : Comparable<R>> ULongArray.maxOfOrNull(     selector: (ULong) -> R ): R? ``` ``` fun <R : Comparable<R>> UByteArray.maxOfOrNull(     selector: (UByte) -> R ): R? ``` ``` fun <R : Comparable<R>> UShortArray.maxOfOrNull(     selector: (UShort) -> R ): R? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](max-of-with) Returns the largest value according to the provided [comparator](max-of-with#kotlin.collections%24maxOfWith(kotlin.Array((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.collections%24maxOfWith(kotlin.Array((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <T, R> Array<out T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` ``` fun <R> ByteArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Byte) -> R ): R ``` ``` fun <R> ShortArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Short) -> R ): R ``` ``` fun <R> IntArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Int) -> R ): R ``` ``` fun <R> LongArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Long) -> R ): R ``` ``` fun <R> FloatArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Float) -> R ): R ``` ``` fun <R> DoubleArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Double) -> R ): R ``` ``` fun <R> BooleanArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R ``` ``` fun <R> CharArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Char) -> R ): R ``` ``` fun <R> UIntArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UInt) -> R ): R ``` ``` fun <R> ULongArray.maxOfWith(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R ``` ``` fun <R> UByteArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UByte) -> R ): R ``` ``` fun <R> UShortArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UShort) -> R ): R ``` Returns the largest value according to the provided [comparator](max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` Returns the largest value according to the provided [comparator](max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.maxOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](max-of-with-or-null) Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.Array((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.Array((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <T, R> Array<out T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` ``` fun <R> ByteArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Byte) -> R ): R? ``` ``` fun <R> ShortArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Short) -> R ): R? ``` ``` fun <R> IntArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Int) -> R ): R? ``` ``` fun <R> LongArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Long) -> R ): R? ``` ``` fun <R> FloatArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Float) -> R ): R? ``` ``` fun <R> DoubleArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Double) -> R ): R? ``` ``` fun <R> BooleanArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R? ``` ``` fun <R> CharArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> R ): R? ``` ``` fun <R> UIntArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UInt) -> R ): R? ``` ``` fun <R> ULongArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R? ``` ``` fun <R> UByteArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UByte) -> R ): R? ``` ``` fun <R> UShortArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UShort) -> R ): R? ``` Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOrNull](max-or-null) Returns the largest element or `null` if there are no elements. ``` fun Array<out Double>.maxOrNull(): Double? ``` ``` fun Array<out Float>.maxOrNull(): Float? ``` ``` fun <T : Comparable<T>> Array<out T>.maxOrNull(): T? ``` ``` fun ByteArray.maxOrNull(): Byte? ``` ``` fun ShortArray.maxOrNull(): Short? ``` ``` fun IntArray.maxOrNull(): Int? ``` ``` fun LongArray.maxOrNull(): Long? ``` ``` fun FloatArray.maxOrNull(): Float? ``` ``` fun DoubleArray.maxOrNull(): Double? ``` ``` fun CharArray.maxOrNull(): Char? ``` ``` fun Iterable<Double>.maxOrNull(): Double? ``` ``` fun Iterable<Float>.maxOrNull(): Float? ``` ``` fun <T : Comparable<T>> Iterable<T>.maxOrNull(): T? ``` ``` fun UIntArray.maxOrNull(): UInt? ``` ``` fun ULongArray.maxOrNull(): ULong? ``` ``` fun UByteArray.maxOrNull(): UByte? ``` ``` fun UShortArray.maxOrNull(): UShort? ``` #### [maxWith](max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](max-with#kotlin.collections%24maxWith(kotlin.Array((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Array<out T>.maxWith(comparator: Comparator<in T>): T ``` ``` fun ByteArray.maxWith(comparator: Comparator<in Byte>): Byte ``` ``` fun ShortArray.maxWith(     comparator: Comparator<in Short> ): Short ``` ``` fun IntArray.maxWith(comparator: Comparator<in Int>): Int ``` ``` fun LongArray.maxWith(comparator: Comparator<in Long>): Long ``` ``` fun FloatArray.maxWith(     comparator: Comparator<in Float> ): Float ``` ``` fun DoubleArray.maxWith(     comparator: Comparator<in Double> ): Double ``` ``` fun BooleanArray.maxWith(     comparator: Comparator<in Boolean> ): Boolean ``` ``` fun CharArray.maxWith(comparator: Comparator<in Char>): Char ``` ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` ``` fun UIntArray.maxWith(comparator: Comparator<in UInt>): UInt ``` ``` fun ULongArray.maxWith(     comparator: Comparator<in ULong> ): ULong ``` ``` fun UByteArray.maxWith(     comparator: Comparator<in UByte> ): UByte ``` ``` fun UShortArray.maxWith(     comparator: Comparator<in UShort> ): UShort ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first entry having the largest value according to the provided [comparator](max-with#kotlin.collections%24maxWith(kotlin.collections.Map((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out T>.maxWith(     comparator: Comparator<in T> ): T? ``` ``` fun ByteArray.maxWith(comparator: Comparator<in Byte>): Byte? ``` ``` fun ShortArray.maxWith(     comparator: Comparator<in Short> ): Short? ``` ``` fun IntArray.maxWith(comparator: Comparator<in Int>): Int? ``` ``` fun LongArray.maxWith(comparator: Comparator<in Long>): Long? ``` ``` fun FloatArray.maxWith(     comparator: Comparator<in Float> ): Float? ``` ``` fun DoubleArray.maxWith(     comparator: Comparator<in Double> ): Double? ``` ``` fun BooleanArray.maxWith(     comparator: Comparator<in Boolean> ): Boolean? ``` ``` fun CharArray.maxWith(comparator: Comparator<in Char>): Char? ``` ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` ``` fun UIntArray.maxWith(comparator: Comparator<in UInt>): UInt? ``` ``` fun ULongArray.maxWith(     comparator: Comparator<in ULong> ): ULong? ``` ``` fun UByteArray.maxWith(     comparator: Comparator<in UByte> ): UByte? ``` ``` fun UShortArray.maxWith(     comparator: Comparator<in UShort> ): UShort? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](max-with-or-null) Returns the first element having the largest value according to the provided [comparator](max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.Array((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Array<out T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` ``` fun ByteArray.maxWithOrNull(     comparator: Comparator<in Byte> ): Byte? ``` ``` fun ShortArray.maxWithOrNull(     comparator: Comparator<in Short> ): Short? ``` ``` fun IntArray.maxWithOrNull(     comparator: Comparator<in Int> ): Int? ``` ``` fun LongArray.maxWithOrNull(     comparator: Comparator<in Long> ): Long? ``` ``` fun FloatArray.maxWithOrNull(     comparator: Comparator<in Float> ): Float? ``` ``` fun DoubleArray.maxWithOrNull(     comparator: Comparator<in Double> ): Double? ``` ``` fun BooleanArray.maxWithOrNull(     comparator: Comparator<in Boolean> ): Boolean? ``` ``` fun CharArray.maxWithOrNull(     comparator: Comparator<in Char> ): Char? ``` ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` ``` fun UIntArray.maxWithOrNull(     comparator: Comparator<in UInt> ): UInt? ``` ``` fun ULongArray.maxWithOrNull(     comparator: Comparator<in ULong> ): ULong? ``` ``` fun UByteArray.maxWithOrNull(     comparator: Comparator<in UByte> ): UByte? ``` ``` fun UShortArray.maxWithOrNull(     comparator: Comparator<in UShort> ): UShort? ``` Returns the first entry having the largest value according to the provided [comparator](max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Map((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` #### <min> Returns the smallest element. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Array<out Double>.min(): Double ``` **Platform and version requirements:** JVM (1.1) ``` fun Array<out Double>.min(): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Array<out Float>.min(): Float ``` **Platform and version requirements:** JVM (1.1) ``` fun Array<out Float>.min(): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T : Comparable<T>> Array<out T>.min(): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T : Comparable<T>> Array<out T>.min(): T? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun ByteArray.min(): Byte ``` **Platform and version requirements:** JVM (1.0) ``` fun ByteArray.min(): Byte? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun ShortArray.min(): Short ``` **Platform and version requirements:** JVM (1.0) ``` fun ShortArray.min(): Short? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun IntArray.min(): Int ``` **Platform and version requirements:** JVM (1.0) ``` fun IntArray.min(): Int? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun LongArray.min(): Long ``` **Platform and version requirements:** JVM (1.0) ``` fun LongArray.min(): Long? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun FloatArray.min(): Float ``` **Platform and version requirements:** JVM (1.0) ``` fun FloatArray.min(): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun DoubleArray.min(): Double ``` **Platform and version requirements:** JVM (1.0) ``` fun DoubleArray.min(): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun CharArray.min(): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun CharArray.min(): Char? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Iterable<Double>.min(): Double ``` **Platform and version requirements:** JVM (1.1) ``` fun Iterable<Double>.min(): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Iterable<Float>.min(): Float ``` **Platform and version requirements:** JVM (1.1) ``` fun Iterable<Float>.min(): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T : Comparable<T>> Iterable<T>.min(): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T : Comparable<T>> Iterable<T>.min(): T? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun UIntArray.min(): UInt ``` **Platform and version requirements:** JVM (1.3) ``` fun UIntArray.min(): UInt? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun ULongArray.min(): ULong ``` **Platform and version requirements:** JVM (1.3) ``` fun ULongArray.min(): ULong? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun UByteArray.min(): UByte ``` **Platform and version requirements:** JVM (1.3) ``` fun UByteArray.min(): UByte? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun UShortArray.min(): UShort ``` **Platform and version requirements:** JVM (1.3) ``` fun UShortArray.min(): UShort? ``` #### [minBy](min-by) Returns the first element yielding the smallest value of the given function. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T, R : Comparable<R>> Array<out T>.minBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T, R : Comparable<R>> Array<out T>.minBy(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> ByteArray.minBy(     selector: (Byte) -> R ): Byte ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> ByteArray.minBy(     selector: (Byte) -> R ): Byte? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> ShortArray.minBy(     selector: (Short) -> R ): Short ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> ShortArray.minBy(     selector: (Short) -> R ): Short? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> IntArray.minBy(     selector: (Int) -> R ): Int ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> IntArray.minBy(     selector: (Int) -> R ): Int? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> LongArray.minBy(     selector: (Long) -> R ): Long ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> LongArray.minBy(     selector: (Long) -> R ): Long? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> FloatArray.minBy(     selector: (Float) -> R ): Float ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> FloatArray.minBy(     selector: (Float) -> R ): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> DoubleArray.minBy(     selector: (Double) -> R ): Double ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> DoubleArray.minBy(     selector: (Double) -> R ): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> BooleanArray.minBy(     selector: (Boolean) -> R ): Boolean ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> BooleanArray.minBy(     selector: (Boolean) -> R ): Boolean? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> CharArray.minBy(     selector: (Char) -> R ): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun <R : Comparable<R>> CharArray.minBy(     selector: (Char) -> R ): Char? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T, R : Comparable<R>> Iterable<T>.minBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T, R : Comparable<R>> Iterable<T>.minBy(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> UIntArray.minBy(     selector: (UInt) -> R ): UInt ``` **Platform and version requirements:** JVM (1.3) ``` fun <R : Comparable<R>> UIntArray.minBy(     selector: (UInt) -> R ): UInt? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> ULongArray.minBy(     selector: (ULong) -> R ): ULong ``` **Platform and version requirements:** JVM (1.3) ``` fun <R : Comparable<R>> ULongArray.minBy(     selector: (ULong) -> R ): ULong? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> UByteArray.minBy(     selector: (UByte) -> R ): UByte ``` **Platform and version requirements:** JVM (1.3) ``` fun <R : Comparable<R>> UByteArray.minBy(     selector: (UByte) -> R ): UByte? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <R : Comparable<R>> UShortArray.minBy(     selector: (UShort) -> R ): UShort ``` **Platform and version requirements:** JVM (1.3) ``` fun <R : Comparable<R>> UShortArray.minBy(     selector: (UShort) -> R ): UShort? ``` Returns the first entry yielding the smallest value of the given function. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(     selector: (Entry<K, V>) -> R ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Array<out T>.minByOrNull(     selector: (T) -> R ): T? ``` ``` fun <R : Comparable<R>> ByteArray.minByOrNull(     selector: (Byte) -> R ): Byte? ``` ``` fun <R : Comparable<R>> ShortArray.minByOrNull(     selector: (Short) -> R ): Short? ``` ``` fun <R : Comparable<R>> IntArray.minByOrNull(     selector: (Int) -> R ): Int? ``` ``` fun <R : Comparable<R>> LongArray.minByOrNull(     selector: (Long) -> R ): Long? ``` ``` fun <R : Comparable<R>> FloatArray.minByOrNull(     selector: (Float) -> R ): Float? ``` ``` fun <R : Comparable<R>> DoubleArray.minByOrNull(     selector: (Double) -> R ): Double? ``` ``` fun <R : Comparable<R>> BooleanArray.minByOrNull(     selector: (Boolean) -> R ): Boolean? ``` ``` fun <R : Comparable<R>> CharArray.minByOrNull(     selector: (Char) -> R ): Char? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` ``` fun <R : Comparable<R>> UIntArray.minByOrNull(     selector: (UInt) -> R ): UInt? ``` ``` fun <R : Comparable<R>> ULongArray.minByOrNull(     selector: (ULong) -> R ): ULong? ``` ``` fun <R : Comparable<R>> UByteArray.minByOrNull(     selector: (UByte) -> R ): UByte? ``` ``` fun <R : Comparable<R>> UShortArray.minByOrNull(     selector: (UShort) -> R ): UShort? ``` Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](min-of) Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.Array((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <T> Array<out T>.minOf(selector: (T) -> Double): Double ``` ``` fun ByteArray.minOf(selector: (Byte) -> Double): Double ``` ``` fun ShortArray.minOf(selector: (Short) -> Double): Double ``` ``` fun IntArray.minOf(selector: (Int) -> Double): Double ``` ``` fun LongArray.minOf(selector: (Long) -> Double): Double ``` ``` fun FloatArray.minOf(selector: (Float) -> Double): Double ``` ``` fun DoubleArray.minOf(selector: (Double) -> Double): Double ``` ``` fun BooleanArray.minOf(selector: (Boolean) -> Double): Double ``` ``` fun CharArray.minOf(selector: (Char) -> Double): Double ``` ``` fun <T> Array<out T>.minOf(selector: (T) -> Float): Float ``` ``` fun ByteArray.minOf(selector: (Byte) -> Float): Float ``` ``` fun ShortArray.minOf(selector: (Short) -> Float): Float ``` ``` fun IntArray.minOf(selector: (Int) -> Float): Float ``` ``` fun LongArray.minOf(selector: (Long) -> Float): Float ``` ``` fun FloatArray.minOf(selector: (Float) -> Float): Float ``` ``` fun DoubleArray.minOf(selector: (Double) -> Float): Float ``` ``` fun BooleanArray.minOf(selector: (Boolean) -> Float): Float ``` ``` fun CharArray.minOf(selector: (Char) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Array<out T>.minOf(     selector: (T) -> R ): R ``` ``` fun <R : Comparable<R>> ByteArray.minOf(     selector: (Byte) -> R ): R ``` ``` fun <R : Comparable<R>> ShortArray.minOf(     selector: (Short) -> R ): R ``` ``` fun <R : Comparable<R>> IntArray.minOf(     selector: (Int) -> R ): R ``` ``` fun <R : Comparable<R>> LongArray.minOf(     selector: (Long) -> R ): R ``` ``` fun <R : Comparable<R>> FloatArray.minOf(     selector: (Float) -> R ): R ``` ``` fun <R : Comparable<R>> DoubleArray.minOf(     selector: (Double) -> R ): R ``` ``` fun <R : Comparable<R>> BooleanArray.minOf(     selector: (Boolean) -> R ): R ``` ``` fun <R : Comparable<R>> CharArray.minOf(     selector: (Char) -> R ): R ``` ``` fun UIntArray.minOf(selector: (UInt) -> Double): Double ``` ``` fun ULongArray.minOf(selector: (ULong) -> Double): Double ``` ``` fun UByteArray.minOf(selector: (UByte) -> Double): Double ``` ``` fun UShortArray.minOf(selector: (UShort) -> Double): Double ``` ``` fun UIntArray.minOf(selector: (UInt) -> Float): Float ``` ``` fun ULongArray.minOf(selector: (ULong) -> Float): Float ``` ``` fun UByteArray.minOf(selector: (UByte) -> Float): Float ``` ``` fun UShortArray.minOf(selector: (UShort) -> Float): Float ``` ``` fun <R : Comparable<R>> UIntArray.minOf(     selector: (UInt) -> R ): R ``` ``` fun <R : Comparable<R>> ULongArray.minOf(     selector: (ULong) -> R ): R ``` ``` fun <R : Comparable<R>> UByteArray.minOf(     selector: (UByte) -> R ): R ``` ``` fun <R : Comparable<R>> UShortArray.minOf(     selector: (UShort) -> R ): R ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](min-of-or-null) Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.Array((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <T> Array<out T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun ByteArray.minOfOrNull(     selector: (Byte) -> Double ): Double? ``` ``` fun ShortArray.minOfOrNull(     selector: (Short) -> Double ): Double? ``` ``` fun IntArray.minOfOrNull(selector: (Int) -> Double): Double? ``` ``` fun LongArray.minOfOrNull(     selector: (Long) -> Double ): Double? ``` ``` fun FloatArray.minOfOrNull(     selector: (Float) -> Double ): Double? ``` ``` fun DoubleArray.minOfOrNull(     selector: (Double) -> Double ): Double? ``` ``` fun BooleanArray.minOfOrNull(     selector: (Boolean) -> Double ): Double? ``` ``` fun CharArray.minOfOrNull(     selector: (Char) -> Double ): Double? ``` ``` fun <T> Array<out T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun ByteArray.minOfOrNull(selector: (Byte) -> Float): Float? ``` ``` fun ShortArray.minOfOrNull(     selector: (Short) -> Float ): Float? ``` ``` fun IntArray.minOfOrNull(selector: (Int) -> Float): Float? ``` ``` fun LongArray.minOfOrNull(selector: (Long) -> Float): Float? ``` ``` fun FloatArray.minOfOrNull(     selector: (Float) -> Float ): Float? ``` ``` fun DoubleArray.minOfOrNull(     selector: (Double) -> Float ): Float? ``` ``` fun BooleanArray.minOfOrNull(     selector: (Boolean) -> Float ): Float? ``` ``` fun CharArray.minOfOrNull(selector: (Char) -> Float): Float? ``` ``` fun <T, R : Comparable<R>> Array<out T>.minOfOrNull(     selector: (T) -> R ): R? ``` ``` fun <R : Comparable<R>> ByteArray.minOfOrNull(     selector: (Byte) -> R ): R? ``` ``` fun <R : Comparable<R>> ShortArray.minOfOrNull(     selector: (Short) -> R ): R? ``` ``` fun <R : Comparable<R>> IntArray.minOfOrNull(     selector: (Int) -> R ): R? ``` ``` fun <R : Comparable<R>> LongArray.minOfOrNull(     selector: (Long) -> R ): R? ``` ``` fun <R : Comparable<R>> FloatArray.minOfOrNull(     selector: (Float) -> R ): R? ``` ``` fun <R : Comparable<R>> DoubleArray.minOfOrNull(     selector: (Double) -> R ): R? ``` ``` fun <R : Comparable<R>> BooleanArray.minOfOrNull(     selector: (Boolean) -> R ): R? ``` ``` fun <R : Comparable<R>> CharArray.minOfOrNull(     selector: (Char) -> R ): R? ``` ``` fun UIntArray.minOfOrNull(     selector: (UInt) -> Double ): Double? ``` ``` fun ULongArray.minOfOrNull(     selector: (ULong) -> Double ): Double? ``` ``` fun UByteArray.minOfOrNull(     selector: (UByte) -> Double ): Double? ``` ``` fun UShortArray.minOfOrNull(     selector: (UShort) -> Double ): Double? ``` ``` fun UIntArray.minOfOrNull(selector: (UInt) -> Float): Float? ``` ``` fun ULongArray.minOfOrNull(     selector: (ULong) -> Float ): Float? ``` ``` fun UByteArray.minOfOrNull(     selector: (UByte) -> Float ): Float? ``` ``` fun UShortArray.minOfOrNull(     selector: (UShort) -> Float ): Float? ``` ``` fun <R : Comparable<R>> UIntArray.minOfOrNull(     selector: (UInt) -> R ): R? ``` ``` fun <R : Comparable<R>> ULongArray.minOfOrNull(     selector: (ULong) -> R ): R? ``` ``` fun <R : Comparable<R>> UByteArray.minOfOrNull(     selector: (UByte) -> R ): R? ``` ``` fun <R : Comparable<R>> UShortArray.minOfOrNull(     selector: (UShort) -> R ): R? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](min-of-with) Returns the smallest value according to the provided [comparator](min-of-with#kotlin.collections%24minOfWith(kotlin.Array((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.collections%24minOfWith(kotlin.Array((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <T, R> Array<out T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` ``` fun <R> ByteArray.minOfWith(     comparator: Comparator<in R>,     selector: (Byte) -> R ): R ``` ``` fun <R> ShortArray.minOfWith(     comparator: Comparator<in R>,     selector: (Short) -> R ): R ``` ``` fun <R> IntArray.minOfWith(     comparator: Comparator<in R>,     selector: (Int) -> R ): R ``` ``` fun <R> LongArray.minOfWith(     comparator: Comparator<in R>,     selector: (Long) -> R ): R ``` ``` fun <R> FloatArray.minOfWith(     comparator: Comparator<in R>,     selector: (Float) -> R ): R ``` ``` fun <R> DoubleArray.minOfWith(     comparator: Comparator<in R>,     selector: (Double) -> R ): R ``` ``` fun <R> BooleanArray.minOfWith(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R ``` ``` fun <R> CharArray.minOfWith(     comparator: Comparator<in R>,     selector: (Char) -> R ): R ``` ``` fun <R> UIntArray.minOfWith(     comparator: Comparator<in R>,     selector: (UInt) -> R ): R ``` ``` fun <R> ULongArray.minOfWith(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R ``` ``` fun <R> UByteArray.minOfWith(     comparator: Comparator<in R>,     selector: (UByte) -> R ): R ``` ``` fun <R> UShortArray.minOfWith(     comparator: Comparator<in R>,     selector: (UShort) -> R ): R ``` Returns the smallest value according to the provided [comparator](min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` Returns the smallest value according to the provided [comparator](min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.minOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](min-of-with-or-null) Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.Array((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.Array((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <T, R> Array<out T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` ``` fun <R> ByteArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Byte) -> R ): R? ``` ``` fun <R> ShortArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Short) -> R ): R? ``` ``` fun <R> IntArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Int) -> R ): R? ``` ``` fun <R> LongArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Long) -> R ): R? ``` ``` fun <R> FloatArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Float) -> R ): R? ``` ``` fun <R> DoubleArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Double) -> R ): R? ``` ``` fun <R> BooleanArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R? ``` ``` fun <R> CharArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> R ): R? ``` ``` fun <R> UIntArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UInt) -> R ): R? ``` ``` fun <R> ULongArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R? ``` ``` fun <R> UByteArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UByte) -> R ): R? ``` ``` fun <R> UShortArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UShort) -> R ): R? ``` Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOrNull](min-or-null) Returns the smallest element or `null` if there are no elements. ``` fun Array<out Double>.minOrNull(): Double? ``` ``` fun Array<out Float>.minOrNull(): Float? ``` ``` fun <T : Comparable<T>> Array<out T>.minOrNull(): T? ``` ``` fun ByteArray.minOrNull(): Byte? ``` ``` fun ShortArray.minOrNull(): Short? ``` ``` fun IntArray.minOrNull(): Int? ``` ``` fun LongArray.minOrNull(): Long? ``` ``` fun FloatArray.minOrNull(): Float? ``` ``` fun DoubleArray.minOrNull(): Double? ``` ``` fun CharArray.minOrNull(): Char? ``` ``` fun Iterable<Double>.minOrNull(): Double? ``` ``` fun Iterable<Float>.minOrNull(): Float? ``` ``` fun <T : Comparable<T>> Iterable<T>.minOrNull(): T? ``` ``` fun UIntArray.minOrNull(): UInt? ``` ``` fun ULongArray.minOrNull(): ULong? ``` ``` fun UByteArray.minOrNull(): UByte? ``` ``` fun UShortArray.minOrNull(): UShort? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <minus> Returns a list containing all elements of the original collection without the first occurrence of the given [element](minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set except the given [element](minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Set<T>.minus(element: T): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> ``` Returns a map containing all entries of the original map except the entry with the given [key](minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.minus.K)/key). ``` operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.Iterable((kotlin.collections.minus.K)))/keys) collection. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Iterable<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.Array((kotlin.collections.minus.K)))/keys) array. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Array<out K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.sequences.Sequence((kotlin.collections.minus.K)))/keys) sequence. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Sequence<K> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](minus-assign) Removes the entry with the given [key](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.minusAssign.K)/key) from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) ``` Removes all entries the keys of which are contained in the given [keys](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.K)))/keys) collection from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Iterable<K>) ``` Removes all entries the keys of which are contained in the given [keys](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.Array((kotlin.collections.minusAssign.K)))/keys) array from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Array<out K>) ``` Removes all entries from the keys of which are contained in the given [keys](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.K)))/keys) sequence from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Sequence<K>) ``` Removes a single instance of the specified [element](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` Returns a set containing all elements of the original set except the given [element](minus-element#kotlin.collections%24minusElement(kotlin.collections.Set((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Set<T>.minusElement(element: T): Set<T> ``` #### [minWith](min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](min-with#kotlin.collections%24minWith(kotlin.Array((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Array<out T>.minWith(comparator: Comparator<in T>): T ``` ``` fun ByteArray.minWith(comparator: Comparator<in Byte>): Byte ``` ``` fun ShortArray.minWith(     comparator: Comparator<in Short> ): Short ``` ``` fun IntArray.minWith(comparator: Comparator<in Int>): Int ``` ``` fun LongArray.minWith(comparator: Comparator<in Long>): Long ``` ``` fun FloatArray.minWith(     comparator: Comparator<in Float> ): Float ``` ``` fun DoubleArray.minWith(     comparator: Comparator<in Double> ): Double ``` ``` fun BooleanArray.minWith(     comparator: Comparator<in Boolean> ): Boolean ``` ``` fun CharArray.minWith(comparator: Comparator<in Char>): Char ``` ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` ``` fun UIntArray.minWith(comparator: Comparator<in UInt>): UInt ``` ``` fun ULongArray.minWith(     comparator: Comparator<in ULong> ): ULong ``` ``` fun UByteArray.minWith(     comparator: Comparator<in UByte> ): UByte ``` ``` fun UShortArray.minWith(     comparator: Comparator<in UShort> ): UShort ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first entry having the smallest value according to the provided [comparator](min-with#kotlin.collections%24minWith(kotlin.collections.Map((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out T>.minWith(     comparator: Comparator<in T> ): T? ``` ``` fun ByteArray.minWith(comparator: Comparator<in Byte>): Byte? ``` ``` fun ShortArray.minWith(     comparator: Comparator<in Short> ): Short? ``` ``` fun IntArray.minWith(comparator: Comparator<in Int>): Int? ``` ``` fun LongArray.minWith(comparator: Comparator<in Long>): Long? ``` ``` fun FloatArray.minWith(     comparator: Comparator<in Float> ): Float? ``` ``` fun DoubleArray.minWith(     comparator: Comparator<in Double> ): Double? ``` ``` fun BooleanArray.minWith(     comparator: Comparator<in Boolean> ): Boolean? ``` ``` fun CharArray.minWith(comparator: Comparator<in Char>): Char? ``` ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` ``` fun UIntArray.minWith(comparator: Comparator<in UInt>): UInt? ``` ``` fun ULongArray.minWith(     comparator: Comparator<in ULong> ): ULong? ``` ``` fun UByteArray.minWith(     comparator: Comparator<in UByte> ): UByte? ``` ``` fun UShortArray.minWith(     comparator: Comparator<in UShort> ): UShort? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.Array((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Array<out T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` ``` fun ByteArray.minWithOrNull(     comparator: Comparator<in Byte> ): Byte? ``` ``` fun ShortArray.minWithOrNull(     comparator: Comparator<in Short> ): Short? ``` ``` fun IntArray.minWithOrNull(     comparator: Comparator<in Int> ): Int? ``` ``` fun LongArray.minWithOrNull(     comparator: Comparator<in Long> ): Long? ``` ``` fun FloatArray.minWithOrNull(     comparator: Comparator<in Float> ): Float? ``` ``` fun DoubleArray.minWithOrNull(     comparator: Comparator<in Double> ): Double? ``` ``` fun BooleanArray.minWithOrNull(     comparator: Comparator<in Boolean> ): Boolean? ``` ``` fun CharArray.minWithOrNull(     comparator: Comparator<in Char> ): Char? ``` ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` ``` fun UIntArray.minWithOrNull(     comparator: Comparator<in UInt> ): UInt? ``` ``` fun ULongArray.minWithOrNull(     comparator: Comparator<in ULong> ): ULong? ``` ``` fun UByteArray.minWithOrNull(     comparator: Comparator<in UByte> ): UByte? ``` ``` fun UShortArray.minWithOrNull(     comparator: Comparator<in UShort> ): UShort? ``` Returns the first entry having the smallest value according to the provided [comparator](min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Map((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [MutableList](-mutable-list) Creates a new mutable list with the specified [size](-mutable-list#kotlin.collections%24MutableList(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.MutableList.T)))/size), where each element is calculated by calling the specified [init](-mutable-list#kotlin.collections%24MutableList(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.MutableList.T)))/init) function. ``` fun <T> MutableList(     size: Int,     init: (index: Int) -> T ): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mutableListOf](mutable-list-of) Returns an empty new [MutableList](-mutable-list/index#kotlin.collections.MutableList). ``` fun <T> mutableListOf(): MutableList<T> ``` Returns a new [MutableList](-mutable-list/index#kotlin.collections.MutableList) with the given elements. ``` fun <T> mutableListOf(vararg elements: T): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mutableMapOf](mutable-map-of) Returns an empty new [MutableMap](-mutable-map/index#kotlin.collections.MutableMap). ``` fun <K, V> mutableMapOf(): MutableMap<K, V> ``` Returns a new [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) with the specified contents, given as a list of pairs where the first component is the key and the second is the value. ``` fun <K, V> mutableMapOf(     vararg pairs: Pair<K, V> ): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mutableSetOf](mutable-set-of) Returns an empty new [MutableSet](-mutable-set/index#kotlin.collections.MutableSet). ``` fun <T> mutableSetOf(): MutableSet<T> ``` Returns a new [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) with the given elements. Elements of the set are iterated in the order they were specified. ``` fun <T> mutableSetOf(vararg elements: T): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <none> Returns `true` if the array has no elements. ``` fun <T> Array<out T>.none(): Boolean ``` ``` fun ByteArray.none(): Boolean ``` ``` fun ShortArray.none(): Boolean ``` ``` fun IntArray.none(): Boolean ``` ``` fun LongArray.none(): Boolean ``` ``` fun FloatArray.none(): Boolean ``` ``` fun DoubleArray.none(): Boolean ``` ``` fun BooleanArray.none(): Boolean ``` ``` fun CharArray.none(): Boolean ``` ``` fun UIntArray.none(): Boolean ``` ``` fun ULongArray.none(): Boolean ``` ``` fun UByteArray.none(): Boolean ``` ``` fun UShortArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](none#kotlin.collections%24none(kotlin.Array((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.none(predicate: (T) -> Boolean): Boolean ``` ``` fun ByteArray.none(predicate: (Byte) -> Boolean): Boolean ``` ``` fun ShortArray.none(predicate: (Short) -> Boolean): Boolean ``` ``` fun IntArray.none(predicate: (Int) -> Boolean): Boolean ``` ``` fun LongArray.none(predicate: (Long) -> Boolean): Boolean ``` ``` fun FloatArray.none(predicate: (Float) -> Boolean): Boolean ``` ``` fun DoubleArray.none(predicate: (Double) -> Boolean): Boolean ``` ``` fun BooleanArray.none(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.none(predicate: (Char) -> Boolean): Boolean ``` ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` ``` fun UIntArray.none(predicate: (UInt) -> Boolean): Boolean ``` ``` fun ULongArray.none(predicate: (ULong) -> Boolean): Boolean ``` ``` fun UByteArray.none(predicate: (UByte) -> Boolean): Boolean ``` ``` fun UShortArray.none(predicate: (UShort) -> Boolean): Boolean ``` Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if the map has no entries. ``` fun <K, V> Map<out K, V>.none(): Boolean ``` Returns `true` if no entries match the given [predicate](none#kotlin.collections%24none(kotlin.collections.Map((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.none(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](on-each) Performs the given [action](on-each#kotlin.collections%24onEach(kotlin.Array((kotlin.collections.onEach.T)),%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun <T> Array<out T>.onEach(     action: (T) -> Unit ): Array<out T> ``` ``` fun ByteArray.onEach(action: (Byte) -> Unit): ByteArray ``` ``` fun ShortArray.onEach(action: (Short) -> Unit): ShortArray ``` ``` fun IntArray.onEach(action: (Int) -> Unit): IntArray ``` ``` fun LongArray.onEach(action: (Long) -> Unit): LongArray ``` ``` fun FloatArray.onEach(action: (Float) -> Unit): FloatArray ``` ``` fun DoubleArray.onEach(action: (Double) -> Unit): DoubleArray ``` ``` fun BooleanArray.onEach(     action: (Boolean) -> Unit ): BooleanArray ``` ``` fun CharArray.onEach(action: (Char) -> Unit): CharArray ``` ``` fun UIntArray.onEach(action: (UInt) -> Unit): UIntArray ``` ``` fun ULongArray.onEach(action: (ULong) -> Unit): ULongArray ``` ``` fun UByteArray.onEach(action: (UByte) -> Unit): UByteArray ``` ``` fun UShortArray.onEach(action: (UShort) -> Unit): UShortArray ``` Performs the given [action](on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` Performs the given [action](on-each#kotlin.collections%24onEach(kotlin.collections.onEach.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.onEach.K,%20kotlin.collections.onEach.V)),%20kotlin.Unit)))/action) on each entry and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEach(     action: (Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](on-each-indexed) Performs the given [action](on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.Array((kotlin.collections.onEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun <T> Array<out T>.onEachIndexed(     action: (index: Int, T) -> Unit ): Array<out T> ``` ``` fun ByteArray.onEachIndexed(     action: (index: Int, Byte) -> Unit ): ByteArray ``` ``` fun ShortArray.onEachIndexed(     action: (index: Int, Short) -> Unit ): ShortArray ``` ``` fun IntArray.onEachIndexed(     action: (index: Int, Int) -> Unit ): IntArray ``` ``` fun LongArray.onEachIndexed(     action: (index: Int, Long) -> Unit ): LongArray ``` ``` fun FloatArray.onEachIndexed(     action: (index: Int, Float) -> Unit ): FloatArray ``` ``` fun DoubleArray.onEachIndexed(     action: (index: Int, Double) -> Unit ): DoubleArray ``` ``` fun BooleanArray.onEachIndexed(     action: (index: Int, Boolean) -> Unit ): BooleanArray ``` ``` fun CharArray.onEachIndexed(     action: (index: Int, Char) -> Unit ): CharArray ``` ``` fun UIntArray.onEachIndexed(     action: (index: Int, UInt) -> Unit ): UIntArray ``` ``` fun ULongArray.onEachIndexed(     action: (index: Int, ULong) -> Unit ): ULongArray ``` ``` fun UByteArray.onEachIndexed(     action: (index: Int, UByte) -> Unit ): UByteArray ``` ``` fun UShortArray.onEachIndexed(     action: (index: Int, UShort) -> Unit ): UShortArray ``` Performs the given [action](on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` Performs the given [action](on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.M,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.Map.Entry((kotlin.collections.onEachIndexed.K,%20kotlin.collections.onEachIndexed.V)),%20kotlin.Unit)))/action) on each entry, providing sequential index with the entry, and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEachIndexed(     action: (index: Int, Entry<K, V>) -> Unit ): M ``` #### [orEmpty](or-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns this Collection if it's not `null` and the empty list otherwise. ``` fun <T> Collection<T>?.orEmpty(): Collection<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns this List if it's not `null` and the empty list otherwise. ``` fun <T> List<T>?.orEmpty(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns the [Map](-map/index#kotlin.collections.Map) if its not `null`, or the empty [Map](-map/index#kotlin.collections.Map) otherwise. ``` fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns this Set if it's not `null` and the empty set otherwise. ``` fun <T> Set<T>?.orEmpty(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1) Returns the array if it's not `null`, or an empty array otherwise. ``` fun <T> any_array<T>.orEmpty(): Array<out T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <partition> Splits the original array into pair of lists, where *first* list contains elements for which [predicate](partition#kotlin.collections%24partition(kotlin.Array((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](partition#kotlin.collections%24partition(kotlin.Array((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> any_array<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](partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` #### <plus> Returns a list containing all elements of the original collection and then the given [element](plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set and then the given [element](plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element) if it isn't already in this set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.plus(element: T): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array, which aren't already in this set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection, which aren't already in this set. The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence, which aren't already in this set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> ``` Returns an array containing all elements of the original array and then the given [element](plus#kotlin.collections%24plus(kotlin.UIntArray,%20kotlin.UInt)/element). **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UIntArray.plus(element: UInt): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun ULongArray.plus(element: ULong): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UByteArray.plus(element: UByte): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UShortArray.plus(element: UShort): UShortArray ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` operator fun <T> Array<T>.plus(element: T): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` operator fun <T> Array<out T>.plus(element: T): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ByteArray.plus(element: Byte): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ShortArray.plus(element: Short): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun IntArray.plus(element: Int): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun LongArray.plus(element: Long): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun FloatArray.plus(element: Float): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun DoubleArray.plus(element: Double): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun BooleanArray.plus(     element: Boolean ): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun CharArray.plus(element: Char): CharArray ``` Returns an array containing all elements of the original array and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.UIntArray,%20kotlin.collections.Collection((kotlin.UInt)))/elements) collection. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UIntArray.plus(     elements: Collection<UInt> ): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun ULongArray.plus(     elements: Collection<ULong> ): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UByteArray.plus(     elements: Collection<UByte> ): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UShortArray.plus(     elements: Collection<UShort> ): UShortArray ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` operator fun <T> Array<T>.plus(     elements: Collection<T> ): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` operator fun <T> Array<out T>.plus(     elements: Collection<T> ): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ByteArray.plus(     elements: Collection<Byte> ): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ShortArray.plus(     elements: Collection<Short> ): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun IntArray.plus(     elements: Collection<Int> ): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun LongArray.plus(     elements: Collection<Long> ): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun FloatArray.plus(     elements: Collection<Float> ): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun DoubleArray.plus(     elements: Collection<Double> ): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun BooleanArray.plus(     elements: Collection<Boolean> ): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun CharArray.plus(     elements: Collection<Char> ): CharArray ``` Returns an array containing all elements of the original array and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.UIntArray,%20kotlin.UIntArray)/elements) array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UIntArray.plus(elements: UIntArray): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun ULongArray.plus(     elements: ULongArray ): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UByteArray.plus(     elements: UByteArray ): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun UShortArray.plus(     elements: UShortArray ): UShortArray ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` operator fun <T> Array<T>.plus(     elements: Array<out T> ): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` operator fun <T> Array<out T>.plus(     elements: Array<out T> ): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ByteArray.plus(elements: ByteArray): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ShortArray.plus(     elements: ShortArray ): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun IntArray.plus(elements: IntArray): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun LongArray.plus(elements: LongArray): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun FloatArray.plus(     elements: FloatArray ): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun DoubleArray.plus(     elements: DoubleArray ): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun BooleanArray.plus(     elements: BooleanArray ): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun CharArray.plus(elements: CharArray): CharArray ``` Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     pair: Pair<K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Iterable<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Array<out Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Sequence<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from another [map](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     map: Map<out K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](plus-assign) Appends or replaces the given [pair](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/pair) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pair: Pair<K, V>) ``` Appends or replaces all pairs from the given collection of [pairs](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Iterable<Pair<K, V>>) ``` Appends or replaces all pairs from the given array of [pairs](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Array<out Pair<K, V>>) ``` Appends or replaces all pairs from the given sequence of [pairs](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Sequence<Pair<K, V>>) ``` Appends or replaces all entries from the given [map](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Map((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/map) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     map: Map<K, V>) ``` Adds the specified [element](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](plus-element) Returns a list containing all elements of the original collection and then the given [element](plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` Returns a set containing all elements of the original set and then the given [element](plus-element#kotlin.collections%24plusElement(kotlin.collections.Set((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element) if it isn't already in this set. ``` fun <T> Set<T>.plusElement(element: T): Set<T> ``` Returns an array containing all elements of the original array and then the given [element](plus-element#kotlin.collections%24plusElement(kotlin.Array((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> any_array<T>.plusElement(element: T): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [putAll](put-all) Puts all the given [pairs](put-all#kotlin.collections%24putAll(kotlin.collections.MutableMap((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)))))/pairs) into this [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Array<out Pair<K, V>>) ``` Puts all the elements of the given collection into this [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Iterable<Pair<K, V>>) ``` Puts all the elements of the given sequence into this [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Sequence<Pair<K, V>>) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <random> Returns a random element from this array. ``` fun <T> Array<out T>.random(): T ``` ``` fun ByteArray.random(): Byte ``` ``` fun ShortArray.random(): Short ``` ``` fun IntArray.random(): Int ``` ``` fun LongArray.random(): Long ``` ``` fun FloatArray.random(): Float ``` ``` fun DoubleArray.random(): Double ``` ``` fun BooleanArray.random(): Boolean ``` ``` fun CharArray.random(): Char ``` ``` fun UIntArray.random(): UInt ``` ``` fun ULongArray.random(): ULong ``` ``` fun UByteArray.random(): UByte ``` ``` fun UShortArray.random(): UShort ``` Returns a random element from this array using the specified source of randomness. ``` fun <T> Array<out T>.random(random: Random): T ``` ``` fun ByteArray.random(random: Random): Byte ``` ``` fun ShortArray.random(random: Random): Short ``` ``` fun IntArray.random(random: Random): Int ``` ``` fun LongArray.random(random: Random): Long ``` ``` fun FloatArray.random(random: Random): Float ``` ``` fun DoubleArray.random(random: Random): Double ``` ``` fun BooleanArray.random(random: Random): Boolean ``` ``` fun CharArray.random(random: Random): Char ``` ``` fun UIntArray.random(random: Random): UInt ``` ``` fun ULongArray.random(random: Random): ULong ``` ``` fun UByteArray.random(random: Random): UByte ``` ``` fun UShortArray.random(random: Random): UShort ``` Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](random-or-null) Returns a random element from this array, or `null` if this array is empty. ``` fun <T> Array<out T>.randomOrNull(): T? ``` ``` fun ByteArray.randomOrNull(): Byte? ``` ``` fun ShortArray.randomOrNull(): Short? ``` ``` fun IntArray.randomOrNull(): Int? ``` ``` fun LongArray.randomOrNull(): Long? ``` ``` fun FloatArray.randomOrNull(): Float? ``` ``` fun DoubleArray.randomOrNull(): Double? ``` ``` fun BooleanArray.randomOrNull(): Boolean? ``` ``` fun CharArray.randomOrNull(): Char? ``` ``` fun UIntArray.randomOrNull(): UInt? ``` ``` fun ULongArray.randomOrNull(): ULong? ``` ``` fun UByteArray.randomOrNull(): UByte? ``` ``` fun UShortArray.randomOrNull(): UShort? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun <T> Array<out T>.randomOrNull(random: Random): T? ``` ``` fun ByteArray.randomOrNull(random: Random): Byte? ``` ``` fun ShortArray.randomOrNull(random: Random): Short? ``` ``` fun IntArray.randomOrNull(random: Random): Int? ``` ``` fun LongArray.randomOrNull(random: Random): Long? ``` ``` fun FloatArray.randomOrNull(random: Random): Float? ``` ``` fun DoubleArray.randomOrNull(random: Random): Double? ``` ``` fun BooleanArray.randomOrNull(random: Random): Boolean? ``` ``` fun CharArray.randomOrNull(random: Random): Char? ``` ``` fun UIntArray.randomOrNull(random: Random): UInt? ``` ``` fun ULongArray.randomOrNull(random: Random): ULong? ``` ``` fun UByteArray.randomOrNull(random: Random): UByte? ``` ``` fun UShortArray.randomOrNull(random: Random): UShort? ``` Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <reduce> Accumulates value starting with the first element and applying [operation](reduce#kotlin.collections%24reduce(kotlin.Array((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Array<out T>.reduce(     operation: (acc: S, T) -> S ): S ``` ``` fun ByteArray.reduce(     operation: (acc: Byte, Byte) -> Byte ): Byte ``` ``` fun ShortArray.reduce(     operation: (acc: Short, Short) -> Short ): Short ``` ``` fun IntArray.reduce(operation: (acc: Int, Int) -> Int): Int ``` ``` fun LongArray.reduce(     operation: (acc: Long, Long) -> Long ): Long ``` ``` fun FloatArray.reduce(     operation: (acc: Float, Float) -> Float ): Float ``` ``` fun DoubleArray.reduce(     operation: (acc: Double, Double) -> Double ): Double ``` ``` fun BooleanArray.reduce(     operation: (acc: Boolean, Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.reduce(     operation: (acc: Char, Char) -> Char ): Char ``` ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` ``` fun UIntArray.reduce(     operation: (acc: UInt, UInt) -> UInt ): UInt ``` ``` fun ULongArray.reduce(     operation: (acc: ULong, ULong) -> ULong ): ULong ``` ``` fun UByteArray.reduce(     operation: (acc: UByte, UByte) -> UByte ): UByte ``` ``` fun UShortArray.reduce(     operation: (acc: UShort, UShort) -> UShort ): UShort ``` Groups elements from the [Grouping](-grouping/index) source by key and applies the reducing [operation](reduce#kotlin.collections%24reduce(kotlin.collections.Grouping((kotlin.collections.reduce.T,%20kotlin.collections.reduce.K)),%20kotlin.Function3((kotlin.collections.reduce.K,%20kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the first element of the group. ``` fun <S, T : S, K> Grouping<T, K>.reduce(     operation: (key: K, accumulator: S, element: T) -> S ): Map<K, S> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](reduce-indexed) Accumulates value starting with the first element and applying [operation](reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.Array((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <S, T : S> Array<out T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` ``` fun ByteArray.reduceIndexed(     operation: (index: Int, acc: Byte, Byte) -> Byte ): Byte ``` ``` fun ShortArray.reduceIndexed(     operation: (index: Int, acc: Short, Short) -> Short ): Short ``` ``` fun IntArray.reduceIndexed(     operation: (index: Int, acc: Int, Int) -> Int ): Int ``` ``` fun LongArray.reduceIndexed(     operation: (index: Int, acc: Long, Long) -> Long ): Long ``` ``` fun FloatArray.reduceIndexed(     operation: (index: Int, acc: Float, Float) -> Float ): Float ``` ``` fun DoubleArray.reduceIndexed(     operation: (index: Int, acc: Double, Double) -> Double ): Double ``` ``` fun BooleanArray.reduceIndexed(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.reduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): Char ``` ``` fun UIntArray.reduceIndexed(     operation: (index: Int, acc: UInt, UInt) -> UInt ): UInt ``` ``` fun ULongArray.reduceIndexed(     operation: (index: Int, acc: ULong, ULong) -> ULong ): ULong ``` ``` fun UByteArray.reduceIndexed(     operation: (index: Int, acc: UByte, UByte) -> UByte ): UByte ``` ``` fun UShortArray.reduceIndexed(     operation: (index: Int, acc: UShort, UShort) -> UShort ): UShort ``` Accumulates value starting with the first element and applying [operation](reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.Array((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <S, T : S> Array<out T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` ``` fun ByteArray.reduceIndexedOrNull(     operation: (index: Int, acc: Byte, Byte) -> Byte ): Byte? ``` ``` fun ShortArray.reduceIndexedOrNull(     operation: (index: Int, acc: Short, Short) -> Short ): Short? ``` ``` fun IntArray.reduceIndexedOrNull(     operation: (index: Int, acc: Int, Int) -> Int ): Int? ``` ``` fun LongArray.reduceIndexedOrNull(     operation: (index: Int, acc: Long, Long) -> Long ): Long? ``` ``` fun FloatArray.reduceIndexedOrNull(     operation: (index: Int, acc: Float, Float) -> Float ): Float? ``` ``` fun DoubleArray.reduceIndexedOrNull(     operation: (index: Int, acc: Double, Double) -> Double ): Double? ``` ``` fun BooleanArray.reduceIndexedOrNull(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.reduceIndexedOrNull(     operation: (index: Int, acc: Char, Char) -> Char ): Char? ``` ``` fun UIntArray.reduceIndexedOrNull(     operation: (index: Int, acc: UInt, UInt) -> UInt ): UInt? ``` ``` fun ULongArray.reduceIndexedOrNull(     operation: (index: Int, acc: ULong, ULong) -> ULong ): ULong? ``` ``` fun UByteArray.reduceIndexedOrNull(     operation: (index: Int, acc: UByte, UByte) -> UByte ): UByte? ``` ``` fun UShortArray.reduceIndexedOrNull(     operation: (index: Int, acc: UShort, UShort) -> UShort ): UShort? ``` Accumulates value starting with the first element and applying [operation](reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](reduce-or-null) Accumulates value starting with the first element and applying [operation](reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.Array((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Array<out T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` ``` fun ByteArray.reduceOrNull(     operation: (acc: Byte, Byte) -> Byte ): Byte? ``` ``` fun ShortArray.reduceOrNull(     operation: (acc: Short, Short) -> Short ): Short? ``` ``` fun IntArray.reduceOrNull(     operation: (acc: Int, Int) -> Int ): Int? ``` ``` fun LongArray.reduceOrNull(     operation: (acc: Long, Long) -> Long ): Long? ``` ``` fun FloatArray.reduceOrNull(     operation: (acc: Float, Float) -> Float ): Float? ``` ``` fun DoubleArray.reduceOrNull(     operation: (acc: Double, Double) -> Double ): Double? ``` ``` fun BooleanArray.reduceOrNull(     operation: (acc: Boolean, Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.reduceOrNull(     operation: (acc: Char, Char) -> Char ): Char? ``` ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` ``` fun UIntArray.reduceOrNull(     operation: (acc: UInt, UInt) -> UInt ): UInt? ``` ``` fun ULongArray.reduceOrNull(     operation: (acc: ULong, ULong) -> ULong ): ULong? ``` ``` fun UByteArray.reduceOrNull(     operation: (acc: UByte, UByte) -> UByte ): UByte? ``` ``` fun UShortArray.reduceOrNull(     operation: (acc: UShort, UShort) -> UShort ): UShort? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](reduce-right) Accumulates value starting with the last element and applying [operation](reduce-right#kotlin.collections%24reduceRight(kotlin.Array((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> Array<out T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` ``` fun ByteArray.reduceRight(     operation: (Byte, acc: Byte) -> Byte ): Byte ``` ``` fun ShortArray.reduceRight(     operation: (Short, acc: Short) -> Short ): Short ``` ``` fun IntArray.reduceRight(     operation: (Int, acc: Int) -> Int ): Int ``` ``` fun LongArray.reduceRight(     operation: (Long, acc: Long) -> Long ): Long ``` ``` fun FloatArray.reduceRight(     operation: (Float, acc: Float) -> Float ): Float ``` ``` fun DoubleArray.reduceRight(     operation: (Double, acc: Double) -> Double ): Double ``` ``` fun BooleanArray.reduceRight(     operation: (Boolean, acc: Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.reduceRight(     operation: (Char, acc: Char) -> Char ): Char ``` ``` fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` ``` fun UIntArray.reduceRight(     operation: (UInt, acc: UInt) -> UInt ): UInt ``` ``` fun ULongArray.reduceRight(     operation: (ULong, acc: ULong) -> ULong ): ULong ``` ``` fun UByteArray.reduceRight(     operation: (UByte, acc: UByte) -> UByte ): UByte ``` ``` fun UShortArray.reduceRight(     operation: (UShort, acc: UShort) -> UShort ): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](reduce-right-indexed) Accumulates value starting with the last element and applying [operation](reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.Array((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun <S, T : S> Array<out T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` ``` fun ByteArray.reduceRightIndexed(     operation: (index: Int, Byte, acc: Byte) -> Byte ): Byte ``` ``` fun ShortArray.reduceRightIndexed(     operation: (index: Int, Short, acc: Short) -> Short ): Short ``` ``` fun IntArray.reduceRightIndexed(     operation: (index: Int, Int, acc: Int) -> Int ): Int ``` ``` fun LongArray.reduceRightIndexed(     operation: (index: Int, Long, acc: Long) -> Long ): Long ``` ``` fun FloatArray.reduceRightIndexed(     operation: (index: Int, Float, acc: Float) -> Float ): Float ``` ``` fun DoubleArray.reduceRightIndexed(     operation: (index: Int, Double, acc: Double) -> Double ): Double ``` ``` fun BooleanArray.reduceRightIndexed(     operation: (index: Int, Boolean, acc: Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.reduceRightIndexed(     operation: (index: Int, Char, acc: Char) -> Char ): Char ``` ``` fun UIntArray.reduceRightIndexed(     operation: (index: Int, UInt, acc: UInt) -> UInt ): UInt ``` ``` fun ULongArray.reduceRightIndexed(     operation: (index: Int, ULong, acc: ULong) -> ULong ): ULong ``` ``` fun UByteArray.reduceRightIndexed(     operation: (index: Int, UByte, acc: UByte) -> UByte ): UByte ``` ``` fun UShortArray.reduceRightIndexed(     operation: (index: Int, UShort, acc: UShort) -> UShort ): UShort ``` Accumulates value starting with the last element and applying [operation](reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.Array((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun <S, T : S> Array<out T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` ``` fun ByteArray.reduceRightIndexedOrNull(     operation: (index: Int, Byte, acc: Byte) -> Byte ): Byte? ``` ``` fun ShortArray.reduceRightIndexedOrNull(     operation: (index: Int, Short, acc: Short) -> Short ): Short? ``` ``` fun IntArray.reduceRightIndexedOrNull(     operation: (index: Int, Int, acc: Int) -> Int ): Int? ``` ``` fun LongArray.reduceRightIndexedOrNull(     operation: (index: Int, Long, acc: Long) -> Long ): Long? ``` ``` fun FloatArray.reduceRightIndexedOrNull(     operation: (index: Int, Float, acc: Float) -> Float ): Float? ``` ``` fun DoubleArray.reduceRightIndexedOrNull(     operation: (index: Int, Double, acc: Double) -> Double ): Double? ``` ``` fun BooleanArray.reduceRightIndexedOrNull(     operation: (index: Int, Boolean, acc: Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.reduceRightIndexedOrNull(     operation: (index: Int, Char, acc: Char) -> Char ): Char? ``` ``` fun UIntArray.reduceRightIndexedOrNull(     operation: (index: Int, UInt, acc: UInt) -> UInt ): UInt? ``` ``` fun ULongArray.reduceRightIndexedOrNull(     operation: (index: Int, ULong, acc: ULong) -> ULong ): ULong? ``` ``` fun UByteArray.reduceRightIndexedOrNull(     operation: (index: Int, UByte, acc: UByte) -> UByte ): UByte? ``` ``` fun UShortArray.reduceRightIndexedOrNull(     operation: (index: Int, UShort, acc: UShort) -> UShort ): UShort? ``` Accumulates value starting with the last element and applying [operation](reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](reduce-right-or-null) Accumulates value starting with the last element and applying [operation](reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.Array((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> Array<out T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` ``` fun ByteArray.reduceRightOrNull(     operation: (Byte, acc: Byte) -> Byte ): Byte? ``` ``` fun ShortArray.reduceRightOrNull(     operation: (Short, acc: Short) -> Short ): Short? ``` ``` fun IntArray.reduceRightOrNull(     operation: (Int, acc: Int) -> Int ): Int? ``` ``` fun LongArray.reduceRightOrNull(     operation: (Long, acc: Long) -> Long ): Long? ``` ``` fun FloatArray.reduceRightOrNull(     operation: (Float, acc: Float) -> Float ): Float? ``` ``` fun DoubleArray.reduceRightOrNull(     operation: (Double, acc: Double) -> Double ): Double? ``` ``` fun BooleanArray.reduceRightOrNull(     operation: (Boolean, acc: Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.reduceRightOrNull(     operation: (Char, acc: Char) -> Char ): Char? ``` ``` fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` ``` fun UIntArray.reduceRightOrNull(     operation: (UInt, acc: UInt) -> UInt ): UInt? ``` ``` fun ULongArray.reduceRightOrNull(     operation: (ULong, acc: ULong) -> ULong ): ULong? ``` ``` fun UByteArray.reduceRightOrNull(     operation: (UByte, acc: UByte) -> UByte ): UByte? ``` ``` fun UShortArray.reduceRightOrNull(     operation: (UShort, acc: UShort) -> UShort ): UShort? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [reduceTo](reduce-to) Groups elements from the [Grouping](-grouping/index) source by key and applies the reducing [operation](reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/operation) to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/destination) map. An initial value of accumulator is the first element of the group. ``` fun <S, T : S, K, M : MutableMap<in K, S>> Grouping<T, K>.reduceTo(     destination: M,     operation: (key: K, accumulator: S, element: T) -> S ): M ``` #### <remove> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Removes the specified key and its corresponding value from this map. ``` fun <K, V> MutableMap<out K, V>.remove(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Removes the element at the specified [index](remove#kotlin.collections%24remove(kotlin.collections.MutableList((kotlin.collections.remove.T)),%20kotlin.Int)/index) from this list. In Kotlin one should use the [MutableList.removeAt](-mutable-list/remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)) function instead. ``` fun <T> MutableList<T>.remove(index: Int): T ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2) Removes the entry for the specified key only if it is currently mapped to the specified value. ``` fun <K, V> MutableMap<out K, out V>.remove(     key: K,     value: V ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` Removes all elements from this [MutableList](-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableList((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirst](remove-first) Removes the first element from this mutable list and returns that removed element, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeFirst(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirstOrNull](remove-first-or-null) Removes the first element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeFirstOrNull(): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLast](remove-last) Removes the last element from this mutable list and returns that removed element, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeLast(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLastOrNull](remove-last-or-null) Removes the last element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeLastOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Array<T?>.requireNoNulls(): Array<T> ``` ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` ``` fun <T : Any> List<T?>.requireNoNulls(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` Retains only elements of this [MutableList](-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableList((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <reverse> Reverses elements in the array in-place. ``` fun <T> Array<T>.reverse() ``` ``` fun ByteArray.reverse() ``` ``` fun ShortArray.reverse() ``` ``` fun IntArray.reverse() ``` ``` fun LongArray.reverse() ``` ``` fun FloatArray.reverse() ``` ``` fun DoubleArray.reverse() ``` ``` fun BooleanArray.reverse() ``` ``` fun CharArray.reverse() ``` ``` fun UIntArray.reverse() ``` ``` fun ULongArray.reverse() ``` ``` fun UByteArray.reverse() ``` ``` fun UShortArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun <T> Array<T>.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun ByteArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun ShortArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun IntArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun LongArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun FloatArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun DoubleArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun BooleanArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun CharArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun UIntArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun ULongArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun UByteArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun UShortArray.reverse(fromIndex: Int, toIndex: Int) ``` Reverses elements in the list in-place. ``` fun <T> MutableList<T>.reverse() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <reversed> Returns a list with elements in reversed order. ``` fun <T> Array<out T>.reversed(): List<T> ``` ``` fun ByteArray.reversed(): List<Byte> ``` ``` fun ShortArray.reversed(): List<Short> ``` ``` fun IntArray.reversed(): List<Int> ``` ``` fun LongArray.reversed(): List<Long> ``` ``` fun FloatArray.reversed(): List<Float> ``` ``` fun DoubleArray.reversed(): List<Double> ``` ``` fun BooleanArray.reversed(): List<Boolean> ``` ``` fun CharArray.reversed(): List<Char> ``` ``` fun <T> Iterable<T>.reversed(): List<T> ``` ``` fun UIntArray.reversed(): List<UInt> ``` ``` fun ULongArray.reversed(): List<ULong> ``` ``` fun UByteArray.reversed(): List<UByte> ``` ``` fun UShortArray.reversed(): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](reversed-array) Returns an array with elements of this array in reversed order. ``` fun <T> Array<T>.reversedArray(): Array<T> ``` ``` fun ByteArray.reversedArray(): ByteArray ``` ``` fun ShortArray.reversedArray(): ShortArray ``` ``` fun IntArray.reversedArray(): IntArray ``` ``` fun LongArray.reversedArray(): LongArray ``` ``` fun FloatArray.reversedArray(): FloatArray ``` ``` fun DoubleArray.reversedArray(): DoubleArray ``` ``` fun BooleanArray.reversedArray(): BooleanArray ``` ``` fun CharArray.reversedArray(): CharArray ``` ``` fun UIntArray.reversedArray(): UIntArray ``` ``` fun ULongArray.reversedArray(): ULongArray ``` ``` fun UByteArray.reversedArray(): UByteArray ``` ``` fun UShortArray.reversedArray(): UShortArray ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](running-fold) Returns a list containing successive accumulation values generated by applying [operation](running-fold#kotlin.collections%24runningFold(kotlin.Array((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](running-fold#kotlin.collections%24runningFold(kotlin.Array((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Array<out T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` ``` fun <R> ByteArray.runningFold(     initial: R,     operation: (acc: R, Byte) -> R ): List<R> ``` ``` fun <R> ShortArray.runningFold(     initial: R,     operation: (acc: R, Short) -> R ): List<R> ``` ``` fun <R> IntArray.runningFold(     initial: R,     operation: (acc: R, Int) -> R ): List<R> ``` ``` fun <R> LongArray.runningFold(     initial: R,     operation: (acc: R, Long) -> R ): List<R> ``` ``` fun <R> FloatArray.runningFold(     initial: R,     operation: (acc: R, Float) -> R ): List<R> ``` ``` fun <R> DoubleArray.runningFold(     initial: R,     operation: (acc: R, Double) -> R ): List<R> ``` ``` fun <R> BooleanArray.runningFold(     initial: R,     operation: (acc: R, Boolean) -> R ): List<R> ``` ``` fun <R> CharArray.runningFold(     initial: R,     operation: (acc: R, Char) -> R ): List<R> ``` ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` ``` fun <R> UIntArray.runningFold(     initial: R,     operation: (acc: R, UInt) -> R ): List<R> ``` ``` fun <R> ULongArray.runningFold(     initial: R,     operation: (acc: R, ULong) -> R ): List<R> ``` ``` fun <R> UByteArray.runningFold(     initial: R,     operation: (acc: R, UByte) -> R ): List<R> ``` ``` fun <R> UShortArray.runningFold(     initial: R,     operation: (acc: R, UShort) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.Array((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with [initial](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.Array((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Array<out T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` ``` fun <R> ByteArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> R ): List<R> ``` ``` fun <R> ShortArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> R ): List<R> ``` ``` fun <R> IntArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> R ): List<R> ``` ``` fun <R> LongArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> R ): List<R> ``` ``` fun <R> FloatArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> R ): List<R> ``` ``` fun <R> DoubleArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> R ): List<R> ``` ``` fun <R> BooleanArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> R ): List<R> ``` ``` fun <R> CharArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): List<R> ``` ``` fun <R> UIntArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> R ): List<R> ``` ``` fun <R> ULongArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): List<R> ``` ``` fun <R> UByteArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> R ): List<R> ``` ``` fun <R> UShortArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, UShort) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](running-reduce) Returns a list containing successive accumulation values generated by applying [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.Array((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun <S, T : S> Array<out T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` ``` fun ByteArray.runningReduce(     operation: (acc: Byte, Byte) -> Byte ): List<Byte> ``` ``` fun ShortArray.runningReduce(     operation: (acc: Short, Short) -> Short ): List<Short> ``` ``` fun IntArray.runningReduce(     operation: (acc: Int, Int) -> Int ): List<Int> ``` ``` fun LongArray.runningReduce(     operation: (acc: Long, Long) -> Long ): List<Long> ``` ``` fun FloatArray.runningReduce(     operation: (acc: Float, Float) -> Float ): List<Float> ``` ``` fun DoubleArray.runningReduce(     operation: (acc: Double, Double) -> Double ): List<Double> ``` ``` fun BooleanArray.runningReduce(     operation: (acc: Boolean, Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.runningReduce(     operation: (acc: Char, Char) -> Char ): List<Char> ``` ``` fun UIntArray.runningReduce(     operation: (acc: UInt, UInt) -> UInt ): List<UInt> ``` ``` fun ULongArray.runningReduce(     operation: (acc: ULong, ULong) -> ULong ): List<ULong> ``` ``` fun UByteArray.runningReduce(     operation: (acc: UByte, UByte) -> UByte ): List<UByte> ``` ``` fun UShortArray.runningReduce(     operation: (acc: UShort, UShort) -> UShort ): List<UShort> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.Array((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with the first element of this array. ``` fun <S, T : S> Array<out T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` ``` fun ByteArray.runningReduceIndexed(     operation: (index: Int, acc: Byte, Byte) -> Byte ): List<Byte> ``` ``` fun ShortArray.runningReduceIndexed(     operation: (index: Int, acc: Short, Short) -> Short ): List<Short> ``` ``` fun IntArray.runningReduceIndexed(     operation: (index: Int, acc: Int, Int) -> Int ): List<Int> ``` ``` fun LongArray.runningReduceIndexed(     operation: (index: Int, acc: Long, Long) -> Long ): List<Long> ``` ``` fun FloatArray.runningReduceIndexed(     operation: (index: Int, acc: Float, Float) -> Float ): List<Float> ``` ``` fun DoubleArray.runningReduceIndexed(     operation: (index: Int, acc: Double, Double) -> Double ): List<Double> ``` ``` fun BooleanArray.runningReduceIndexed(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.runningReduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): List<Char> ``` ``` fun UIntArray.runningReduceIndexed(     operation: (index: Int, acc: UInt, UInt) -> UInt ): List<UInt> ``` ``` fun ULongArray.runningReduceIndexed(     operation: (index: Int, acc: ULong, ULong) -> ULong ): List<ULong> ``` ``` fun UByteArray.runningReduceIndexed(     operation: (index: Int, acc: UByte, UByte) -> UByte ): List<UByte> ``` ``` fun UShortArray.runningReduceIndexed(     operation: (index: Int, acc: UShort, UShort) -> UShort ): List<UShort> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### <scan> Returns a list containing successive accumulation values generated by applying [operation](scan#kotlin.collections%24scan(kotlin.Array((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](scan#kotlin.collections%24scan(kotlin.Array((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Array<out T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` ``` fun <R> ByteArray.scan(     initial: R,     operation: (acc: R, Byte) -> R ): List<R> ``` ``` fun <R> ShortArray.scan(     initial: R,     operation: (acc: R, Short) -> R ): List<R> ``` ``` fun <R> IntArray.scan(     initial: R,     operation: (acc: R, Int) -> R ): List<R> ``` ``` fun <R> LongArray.scan(     initial: R,     operation: (acc: R, Long) -> R ): List<R> ``` ``` fun <R> FloatArray.scan(     initial: R,     operation: (acc: R, Float) -> R ): List<R> ``` ``` fun <R> DoubleArray.scan(     initial: R,     operation: (acc: R, Double) -> R ): List<R> ``` ``` fun <R> BooleanArray.scan(     initial: R,     operation: (acc: R, Boolean) -> R ): List<R> ``` ``` fun <R> CharArray.scan(     initial: R,     operation: (acc: R, Char) -> R ): List<R> ``` ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` ``` fun <R> UIntArray.scan(     initial: R,     operation: (acc: R, UInt) -> R ): List<R> ``` ``` fun <R> ULongArray.scan(     initial: R,     operation: (acc: R, ULong) -> R ): List<R> ``` ``` fun <R> UByteArray.scan(     initial: R,     operation: (acc: R, UByte) -> R ): List<R> ``` ``` fun <R> UShortArray.scan(     initial: R,     operation: (acc: R, UShort) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](scan-indexed#kotlin.collections%24scanIndexed(kotlin.Array((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with [initial](scan-indexed#kotlin.collections%24scanIndexed(kotlin.Array((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Array<out T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` ``` fun <R> ByteArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> R ): List<R> ``` ``` fun <R> ShortArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> R ): List<R> ``` ``` fun <R> IntArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> R ): List<R> ``` ``` fun <R> LongArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> R ): List<R> ``` ``` fun <R> FloatArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> R ): List<R> ``` ``` fun <R> DoubleArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> R ): List<R> ``` ``` fun <R> BooleanArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> R ): List<R> ``` ``` fun <R> CharArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): List<R> ``` ``` fun <R> UIntArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> R ): List<R> ``` ``` fun <R> ULongArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): List<R> ``` ``` fun <R> UByteArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> R ): List<R> ``` ``` fun <R> UShortArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, UShort) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Allows to use the index operator for storing values in a mutable map. ``` operator fun <K, V> MutableMap<K, V>.set(key: K, value: V) ``` #### [setOf](set-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a new read-only set with the given elements. Elements of the set are iterated in the order they were specified. The returned set is serializable (JVM). ``` fun <T> setOf(vararg elements: T): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns an empty read-only set. The returned set is serializable (JVM). ``` fun <T> setOf(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1) Returns an immutable set containing only the specified object [element](set-of#kotlin.collections%24setOf(kotlin.collections.setOf.T)/element). The returned set is serializable. ``` fun <T> setOf(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [setOfNotNull](set-of-not-null) Returns a new read-only set either with single given element, if it is not null, or empty set if the element is null. The returned set is serializable (JVM). ``` fun <T : Any> setOfNotNull(element: T?): Set<T> ``` Returns a new read-only set only with those given elements, that are not null. Elements of the set are iterated in the order they were specified. The returned set is serializable (JVM). ``` fun <T : Any> setOfNotNull(vararg elements: T?): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [setValue](set-value) Stores the value of the property for the given object in this mutable map. ``` operator fun <V> MutableMap<in String, in V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` #### <shuffle> **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) Randomly shuffles elements in this array in-place. ``` fun <T> Array<T>.shuffle() ``` ``` fun ByteArray.shuffle() ``` ``` fun ShortArray.shuffle() ``` ``` fun IntArray.shuffle() ``` ``` fun LongArray.shuffle() ``` ``` fun FloatArray.shuffle() ``` ``` fun DoubleArray.shuffle() ``` ``` fun BooleanArray.shuffle() ``` ``` fun CharArray.shuffle() ``` ``` fun UIntArray.shuffle() ``` ``` fun ULongArray.shuffle() ``` ``` fun UByteArray.shuffle() ``` ``` fun UShortArray.shuffle() ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) Randomly shuffles elements in this array in-place using the specified [random](shuffle#kotlin.collections%24shuffle(kotlin.Array((kotlin.collections.shuffle.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Array<T>.shuffle(random: Random) ``` ``` fun ByteArray.shuffle(random: Random) ``` ``` fun ShortArray.shuffle(random: Random) ``` ``` fun IntArray.shuffle(random: Random) ``` ``` fun LongArray.shuffle(random: Random) ``` ``` fun FloatArray.shuffle(random: Random) ``` ``` fun DoubleArray.shuffle(random: Random) ``` ``` fun BooleanArray.shuffle(random: Random) ``` ``` fun CharArray.shuffle(random: Random) ``` ``` fun UIntArray.shuffle(random: Random) ``` ``` fun ULongArray.shuffle(random: Random) ``` ``` fun UByteArray.shuffle(random: Random) ``` ``` fun UShortArray.shuffle(random: Random) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) Randomly shuffles elements in this list in-place using the specified [random](shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> MutableList<T>.shuffle(random: Random) ``` **Platform and version requirements:** JVM (1.2) Randomly shuffles elements in this mutable list using the specified [random](shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20java.util.Random)/random) instance as the source of randomness. ``` fun <T> MutableList<T>.shuffle(random: Random) ``` **Platform and version requirements:** JVM (1.2), JS (1.2) Randomly shuffles elements in this mutable list. ``` fun <T> MutableList<T>.shuffle() ``` #### <shuffled> Returns a new list with the elements of this list randomly shuffled using the specified [random](shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` Returns a new list with the elements of this list randomly shuffled. **Platform and version requirements:** JVM (1.2), JS (1.2) ``` fun <T> Iterable<T>.shuffled(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <single> Returns the single element, or throws an exception if the array is empty or has more than one element. ``` fun <T> Array<out T>.single(): T ``` ``` fun ByteArray.single(): Byte ``` ``` fun ShortArray.single(): Short ``` ``` fun IntArray.single(): Int ``` ``` fun LongArray.single(): Long ``` ``` fun FloatArray.single(): Float ``` ``` fun DoubleArray.single(): Double ``` ``` fun BooleanArray.single(): Boolean ``` ``` fun CharArray.single(): Char ``` ``` fun UIntArray.single(): UInt ``` ``` fun ULongArray.single(): ULong ``` ``` fun UByteArray.single(): UByte ``` ``` fun UShortArray.single(): UShort ``` Returns the single element matching the given [predicate](single#kotlin.collections%24single(kotlin.Array((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Array<out T>.single(predicate: (T) -> Boolean): T ``` ``` fun ByteArray.single(predicate: (Byte) -> Boolean): Byte ``` ``` fun ShortArray.single(predicate: (Short) -> Boolean): Short ``` ``` fun IntArray.single(predicate: (Int) -> Boolean): Int ``` ``` fun LongArray.single(predicate: (Long) -> Boolean): Long ``` ``` fun FloatArray.single(predicate: (Float) -> Boolean): Float ``` ``` fun DoubleArray.single(     predicate: (Double) -> Boolean ): Double ``` ``` fun BooleanArray.single(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` fun CharArray.single(predicate: (Char) -> Boolean): Char ``` ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` ``` fun UIntArray.single(predicate: (UInt) -> Boolean): UInt ``` ``` fun ULongArray.single(predicate: (ULong) -> Boolean): ULong ``` ``` fun UByteArray.single(predicate: (UByte) -> Boolean): UByte ``` ``` fun UShortArray.single(     predicate: (UShort) -> Boolean ): UShort ``` Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element, or throws an exception if the list is empty or has more than one element. ``` fun <T> List<T>.single(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](single-or-null) Returns single element, or `null` if the array is empty or has more than one element. ``` fun <T> Array<out T>.singleOrNull(): T? ``` ``` fun ByteArray.singleOrNull(): Byte? ``` ``` fun ShortArray.singleOrNull(): Short? ``` ``` fun IntArray.singleOrNull(): Int? ``` ``` fun LongArray.singleOrNull(): Long? ``` ``` fun FloatArray.singleOrNull(): Float? ``` ``` fun DoubleArray.singleOrNull(): Double? ``` ``` fun BooleanArray.singleOrNull(): Boolean? ``` ``` fun CharArray.singleOrNull(): Char? ``` ``` fun UIntArray.singleOrNull(): UInt? ``` ``` fun ULongArray.singleOrNull(): ULong? ``` ``` fun UByteArray.singleOrNull(): UByte? ``` ``` fun UShortArray.singleOrNull(): UShort? ``` Returns the single element matching the given [predicate](single-or-null#kotlin.collections%24singleOrNull(kotlin.Array((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Array<out T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` ``` fun ByteArray.singleOrNull(     predicate: (Byte) -> Boolean ): Byte? ``` ``` fun ShortArray.singleOrNull(     predicate: (Short) -> Boolean ): Short? ``` ``` fun IntArray.singleOrNull(predicate: (Int) -> Boolean): Int? ``` ``` fun LongArray.singleOrNull(     predicate: (Long) -> Boolean ): Long? ``` ``` fun FloatArray.singleOrNull(     predicate: (Float) -> Boolean ): Float? ``` ``` fun DoubleArray.singleOrNull(     predicate: (Double) -> Boolean ): Double? ``` ``` fun BooleanArray.singleOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` fun CharArray.singleOrNull(     predicate: (Char) -> Boolean ): Char? ``` ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` ``` fun UIntArray.singleOrNull(     predicate: (UInt) -> Boolean ): UInt? ``` ``` fun ULongArray.singleOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` fun UByteArray.singleOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` fun UShortArray.singleOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns single element, or `null` if the list is empty or has more than one element. ``` fun <T> List<T>.singleOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <slice> Returns a list containing elements at indices in the specified [indices](slice#kotlin.collections%24slice(kotlin.Array((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> Array<out T>.slice(indices: IntRange): List<T> ``` ``` fun ByteArray.slice(indices: IntRange): List<Byte> ``` ``` fun ShortArray.slice(indices: IntRange): List<Short> ``` ``` fun IntArray.slice(indices: IntRange): List<Int> ``` ``` fun LongArray.slice(indices: IntRange): List<Long> ``` ``` fun FloatArray.slice(indices: IntRange): List<Float> ``` ``` fun DoubleArray.slice(indices: IntRange): List<Double> ``` ``` fun BooleanArray.slice(indices: IntRange): List<Boolean> ``` ``` fun CharArray.slice(indices: IntRange): List<Char> ``` ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` ``` fun UIntArray.slice(indices: IntRange): List<UInt> ``` ``` fun ULongArray.slice(indices: IntRange): List<ULong> ``` ``` fun UByteArray.slice(indices: IntRange): List<UByte> ``` ``` fun UShortArray.slice(indices: IntRange): List<UShort> ``` Returns a list containing elements at specified [indices](slice#kotlin.collections%24slice(kotlin.Array((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun <T> Array<out T>.slice(indices: Iterable<Int>): List<T> ``` ``` fun ByteArray.slice(indices: Iterable<Int>): List<Byte> ``` ``` fun ShortArray.slice(indices: Iterable<Int>): List<Short> ``` ``` fun IntArray.slice(indices: Iterable<Int>): List<Int> ``` ``` fun LongArray.slice(indices: Iterable<Int>): List<Long> ``` ``` fun FloatArray.slice(indices: Iterable<Int>): List<Float> ``` ``` fun DoubleArray.slice(indices: Iterable<Int>): List<Double> ``` ``` fun BooleanArray.slice(indices: Iterable<Int>): List<Boolean> ``` ``` fun CharArray.slice(indices: Iterable<Int>): List<Char> ``` ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` ``` fun UIntArray.slice(indices: Iterable<Int>): List<UInt> ``` ``` fun ULongArray.slice(indices: Iterable<Int>): List<ULong> ``` ``` fun UByteArray.slice(indices: Iterable<Int>): List<UByte> ``` ``` fun UShortArray.slice(indices: Iterable<Int>): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](slice-array) Returns an array containing elements of this array at specified [indices](slice-array#kotlin.collections%24sliceArray(kotlin.Array((kotlin.collections.sliceArray.T)),%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun <T> Array<T>.sliceArray(     indices: Collection<Int> ): Array<T> ``` ``` fun ByteArray.sliceArray(indices: Collection<Int>): ByteArray ``` ``` fun ShortArray.sliceArray(     indices: Collection<Int> ): ShortArray ``` ``` fun IntArray.sliceArray(indices: Collection<Int>): IntArray ``` ``` fun LongArray.sliceArray(indices: Collection<Int>): LongArray ``` ``` fun FloatArray.sliceArray(     indices: Collection<Int> ): FloatArray ``` ``` fun DoubleArray.sliceArray(     indices: Collection<Int> ): DoubleArray ``` ``` fun BooleanArray.sliceArray(     indices: Collection<Int> ): BooleanArray ``` ``` fun CharArray.sliceArray(indices: Collection<Int>): CharArray ``` ``` fun UIntArray.sliceArray(indices: Collection<Int>): UIntArray ``` ``` fun ULongArray.sliceArray(     indices: Collection<Int> ): ULongArray ``` ``` fun UByteArray.sliceArray(     indices: Collection<Int> ): UByteArray ``` ``` fun UShortArray.sliceArray(     indices: Collection<Int> ): UShortArray ``` Returns an array containing elements at indices in the specified [indices](slice-array#kotlin.collections%24sliceArray(kotlin.Array((kotlin.collections.sliceArray.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> Array<T>.sliceArray(indices: IntRange): Array<T> ``` ``` fun ByteArray.sliceArray(indices: IntRange): ByteArray ``` ``` fun ShortArray.sliceArray(indices: IntRange): ShortArray ``` ``` fun IntArray.sliceArray(indices: IntRange): IntArray ``` ``` fun LongArray.sliceArray(indices: IntRange): LongArray ``` ``` fun FloatArray.sliceArray(indices: IntRange): FloatArray ``` ``` fun DoubleArray.sliceArray(indices: IntRange): DoubleArray ``` ``` fun BooleanArray.sliceArray(indices: IntRange): BooleanArray ``` ``` fun CharArray.sliceArray(indices: IntRange): CharArray ``` ``` fun UIntArray.sliceArray(indices: IntRange): UIntArray ``` ``` fun ULongArray.sliceArray(indices: IntRange): ULongArray ``` ``` fun UByteArray.sliceArray(indices: IntRange): UByteArray ``` ``` fun UShortArray.sliceArray(indices: IntRange): UShortArray ``` #### <sort> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) Sorts the array in-place. ``` fun UIntArray.sort() ``` ``` fun ULongArray.sort() ``` ``` fun UByteArray.sort() ``` ``` fun UShortArray.sort() ``` ``` fun IntArray.sort() ``` ``` fun LongArray.sort() ``` ``` fun ByteArray.sort() ``` ``` fun ShortArray.sort() ``` ``` fun DoubleArray.sort() ``` ``` fun FloatArray.sort() ``` ``` fun CharArray.sort() ``` **Platform and version requirements:** JVM (1.0), JS (1.4), Native (1.4) Sorts a range in the array in-place. ``` fun UIntArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun ULongArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun UByteArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun UShortArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun <T : Comparable<T>> Array<out T>.sort(     fromIndex: Int = 0,     toIndex: Int = size) ``` ``` fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` ``` fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size) ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> MutableList<T>.sort(comparator: Comparator<in T>) ``` ``` fun <T> MutableList<T>.sort(comparison: (T, T) -> Int) ``` **Platform and version requirements:** JS (1.1) Sorts the array in-place according to the order specified by the given [comparison](sort#kotlin.collections%24sort(kotlin.Array((kotlin.collections.sort.T)),%20kotlin.Function2((kotlin.collections.sort.T,%20,%20kotlin.Int)))/comparison) function. ``` fun <T> any_array<T>.sort(comparison: (a: T, b: T) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) Sorts the array in-place according to the natural order of its elements. ``` fun <T : Comparable<T>> any_array<T>.sort() ``` **Platform and version requirements:** JVM (1.0), JS (1.1) Sorts elements in the list in-place according to their natural sort order. ``` fun <T : Comparable<T>> MutableList<T>.sort() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortBy](sort-by) Sorts elements in the array in-place according to natural sort order of the value returned by specified [selector](sort-by#kotlin.collections%24sortBy(kotlin.Array((kotlin.collections.sortBy.T)),%20kotlin.Function1((kotlin.collections.sortBy.T,%20kotlin.collections.sortBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Array<out T>.sortBy(     selector: (T) -> R?) ``` Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector](sort-by#kotlin.collections%24sortBy(kotlin.collections.MutableList((kotlin.collections.sortBy.T)),%20kotlin.Function1((kotlin.collections.sortBy.T,%20kotlin.collections.sortBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortBy(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortByDescending](sort-by-descending) Sorts elements in the array in-place descending according to natural sort order of the value returned by specified [selector](sort-by-descending#kotlin.collections%24sortByDescending(kotlin.Array((kotlin.collections.sortByDescending.T)),%20kotlin.Function1((kotlin.collections.sortByDescending.T,%20kotlin.collections.sortByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Array<out T>.sortByDescending(     selector: (T) -> R?) ``` Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector](sort-by-descending#kotlin.collections%24sortByDescending(kotlin.collections.MutableList((kotlin.collections.sortByDescending.T)),%20kotlin.Function1((kotlin.collections.sortByDescending.T,%20kotlin.collections.sortByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun <T : Comparable<T>> Array<out T>.sortDescending() ``` ``` fun ByteArray.sortDescending() ``` ``` fun ShortArray.sortDescending() ``` ``` fun IntArray.sortDescending() ``` ``` fun LongArray.sortDescending() ``` ``` fun FloatArray.sortDescending() ``` ``` fun DoubleArray.sortDescending() ``` ``` fun CharArray.sortDescending() ``` ``` fun UIntArray.sortDescending() ``` ``` fun ULongArray.sortDescending() ``` ``` fun UByteArray.sortDescending() ``` ``` fun UShortArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun <T : Comparable<T>> Array<out T>.sortDescending(     fromIndex: Int,     toIndex: Int) ``` ``` fun ByteArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun ShortArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun IntArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun LongArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun FloatArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun DoubleArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun CharArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun UIntArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun ULongArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun UByteArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun UShortArray.sortDescending(fromIndex: Int, toIndex: Int) ``` Sorts elements in the list in-place descending according to their natural sort order. ``` fun <T : Comparable<T>> MutableList<T>.sortDescending() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <sorted> Returns a list of all elements sorted according to their natural sort order. ``` fun <T : Comparable<T>> Array<out T>.sorted(): List<T> ``` ``` fun ByteArray.sorted(): List<Byte> ``` ``` fun ShortArray.sorted(): List<Short> ``` ``` fun IntArray.sorted(): List<Int> ``` ``` fun LongArray.sorted(): List<Long> ``` ``` fun FloatArray.sorted(): List<Float> ``` ``` fun DoubleArray.sorted(): List<Double> ``` ``` fun CharArray.sorted(): List<Char> ``` ``` fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> ``` ``` fun UIntArray.sorted(): List<UInt> ``` ``` fun ULongArray.sorted(): List<ULong> ``` ``` fun UByteArray.sorted(): List<UByte> ``` ``` fun UShortArray.sorted(): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun <T : Comparable<T>> Array<T>.sortedArray(): Array<T> ``` ``` fun ByteArray.sortedArray(): ByteArray ``` ``` fun ShortArray.sortedArray(): ShortArray ``` ``` fun IntArray.sortedArray(): IntArray ``` ``` fun LongArray.sortedArray(): LongArray ``` ``` fun FloatArray.sortedArray(): FloatArray ``` ``` fun DoubleArray.sortedArray(): DoubleArray ``` ``` fun CharArray.sortedArray(): CharArray ``` ``` fun UIntArray.sortedArray(): UIntArray ``` ``` fun ULongArray.sortedArray(): ULongArray ``` ``` fun UByteArray.sortedArray(): UByteArray ``` ``` fun UShortArray.sortedArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun <T : Comparable<T>> Array<T>.sortedArrayDescending(): Array<T> ``` ``` fun ByteArray.sortedArrayDescending(): ByteArray ``` ``` fun ShortArray.sortedArrayDescending(): ShortArray ``` ``` fun IntArray.sortedArrayDescending(): IntArray ``` ``` fun LongArray.sortedArrayDescending(): LongArray ``` ``` fun FloatArray.sortedArrayDescending(): FloatArray ``` ``` fun DoubleArray.sortedArrayDescending(): DoubleArray ``` ``` fun CharArray.sortedArrayDescending(): CharArray ``` ``` fun UIntArray.sortedArrayDescending(): UIntArray ``` ``` fun ULongArray.sortedArrayDescending(): ULongArray ``` ``` fun UByteArray.sortedArrayDescending(): UByteArray ``` ``` fun UShortArray.sortedArrayDescending(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayWith](sorted-array-with) Returns an array with all elements of this array sorted according the specified [comparator](sorted-array-with#kotlin.collections%24sortedArrayWith(kotlin.Array((kotlin.collections.sortedArrayWith.T)),%20kotlin.Comparator((kotlin.collections.sortedArrayWith.T)))/comparator). ``` fun <T> Array<out T>.sortedArrayWith(     comparator: Comparator<in T> ): Array<out T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](sorted-by#kotlin.collections%24sortedBy(kotlin.Array((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Array<out T>.sortedBy(     selector: (T) -> R? ): List<T> ``` ``` fun <R : Comparable<R>> ByteArray.sortedBy(     selector: (Byte) -> R? ): List<Byte> ``` ``` fun <R : Comparable<R>> ShortArray.sortedBy(     selector: (Short) -> R? ): List<Short> ``` ``` fun <R : Comparable<R>> IntArray.sortedBy(     selector: (Int) -> R? ): List<Int> ``` ``` fun <R : Comparable<R>> LongArray.sortedBy(     selector: (Long) -> R? ): List<Long> ``` ``` fun <R : Comparable<R>> FloatArray.sortedBy(     selector: (Float) -> R? ): List<Float> ``` ``` fun <R : Comparable<R>> DoubleArray.sortedBy(     selector: (Double) -> R? ): List<Double> ``` ``` fun <R : Comparable<R>> BooleanArray.sortedBy(     selector: (Boolean) -> R? ): List<Boolean> ``` ``` fun <R : Comparable<R>> CharArray.sortedBy(     selector: (Char) -> R? ): List<Char> ``` ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.Array((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Array<out T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` ``` fun <R : Comparable<R>> ByteArray.sortedByDescending(     selector: (Byte) -> R? ): List<Byte> ``` ``` fun <R : Comparable<R>> ShortArray.sortedByDescending(     selector: (Short) -> R? ): List<Short> ``` ``` fun <R : Comparable<R>> IntArray.sortedByDescending(     selector: (Int) -> R? ): List<Int> ``` ``` fun <R : Comparable<R>> LongArray.sortedByDescending(     selector: (Long) -> R? ): List<Long> ``` ``` fun <R : Comparable<R>> FloatArray.sortedByDescending(     selector: (Float) -> R? ): List<Float> ``` ``` fun <R : Comparable<R>> DoubleArray.sortedByDescending(     selector: (Double) -> R? ): List<Double> ``` ``` fun <R : Comparable<R>> BooleanArray.sortedByDescending(     selector: (Boolean) -> R? ): List<Boolean> ``` ``` fun <R : Comparable<R>> CharArray.sortedByDescending(     selector: (Char) -> R? ): List<Char> ``` ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun <T : Comparable<T>> Array<out T>.sortedDescending(): List<T> ``` ``` fun ByteArray.sortedDescending(): List<Byte> ``` ``` fun ShortArray.sortedDescending(): List<Short> ``` ``` fun IntArray.sortedDescending(): List<Int> ``` ``` fun LongArray.sortedDescending(): List<Long> ``` ``` fun FloatArray.sortedDescending(): List<Float> ``` ``` fun DoubleArray.sortedDescending(): List<Double> ``` ``` fun CharArray.sortedDescending(): List<Char> ``` ``` fun <T : Comparable<T>> Iterable<T>.sortedDescending(): List<T> ``` ``` fun UIntArray.sortedDescending(): List<UInt> ``` ``` fun ULongArray.sortedDescending(): List<ULong> ``` ``` fun UByteArray.sortedDescending(): List<UByte> ``` ``` fun UShortArray.sortedDescending(): List<UShort> ``` **Platform and version requirements:** JVM (1.0) #### [sortedMapOf](sorted-map-of) Returns a new [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) with the specified contents, given as a list of pairs where the first value is the key and the second is the value. ``` fun <K : Comparable<K>, V> sortedMapOf(     vararg pairs: Pair<K, V> ): SortedMap<K, V> ``` ``` fun <K, V> sortedMapOf(     comparator: Comparator<in K>,     vararg pairs: Pair<K, V> ): SortedMap<K, V> ``` **Platform and version requirements:** JVM (1.0) #### [sortedSetOf](sorted-set-of) Returns a new [java.util.SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) with the given elements. ``` fun <T> sortedSetOf(vararg elements: T): TreeSet<T> ``` Returns a new [java.util.SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) with the given [comparator](sorted-set-of#kotlin.collections%24sortedSetOf(java.util.Comparator((kotlin.collections.sortedSetOf.T)),%20kotlin.Array((kotlin.collections.sortedSetOf.T)))/comparator) and elements. ``` fun <T> sortedSetOf(     comparator: Comparator<in T>,     vararg elements: T ): TreeSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](sorted-with) Returns a list of all elements sorted according to the specified [comparator](sorted-with#kotlin.collections%24sortedWith(kotlin.Array((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Array<out T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` ``` fun ByteArray.sortedWith(     comparator: Comparator<in Byte> ): List<Byte> ``` ``` fun ShortArray.sortedWith(     comparator: Comparator<in Short> ): List<Short> ``` ``` fun IntArray.sortedWith(     comparator: Comparator<in Int> ): List<Int> ``` ``` fun LongArray.sortedWith(     comparator: Comparator<in Long> ): List<Long> ``` ``` fun FloatArray.sortedWith(     comparator: Comparator<in Float> ): List<Float> ``` ``` fun DoubleArray.sortedWith(     comparator: Comparator<in Double> ): List<Double> ``` ``` fun BooleanArray.sortedWith(     comparator: Comparator<in Boolean> ): List<Boolean> ``` ``` fun CharArray.sortedWith(     comparator: Comparator<in Char> ): List<Char> ``` ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` #### [sortWith](sort-with) Sorts the array in-place according to the order specified by the given [comparator](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)))/comparator). **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun <T> any_array<T>.sortWith(comparator: Comparator<in T>) ``` Sorts a range in the array in-place with the given [comparator](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/comparator). **Platform and version requirements:** JVM (1.0), JS (1.4), Native (1.3) ``` fun <T> any_array<T>.sortWith(     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size) ``` Sorts elements in the list in-place according to the order specified with [comparator](sort-with#kotlin.collections%24sortWith(kotlin.collections.MutableList((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)))/comparator). **Platform and version requirements:** JVM (1.0) ``` fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>) ``` **Platform and version requirements:** JS (1.1) ``` fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>) ``` **Platform and version requirements:** JS (1.1) #### [stringMapOf](string-map-of) Constructs the specialized implementation of [HashMap](-hash-map/index#kotlin.collections.HashMap) with String keys, which stores the keys as properties of JS object without hashing them. ``` fun <V> stringMapOf(     vararg pairs: Pair<String, V> ): HashMap<String, V> ``` **Platform and version requirements:** JS (1.1) #### [stringSetOf](string-set-of) Creates a new instance of the specialized implementation of [HashSet](-hash-set/index#kotlin.collections.HashSet) with the specified String elements, which elements the keys as properties of JS object without hashing them. ``` fun stringSetOf(vararg elements: String): HashSet<String> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <subtract> Returns a set containing all elements that are contained by this array and not contained by the specified collection. ``` infix fun <T> any_array<T>.subtract(     other: Iterable<T> ): Set<T> ``` Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <sum> Returns the sum of all elements in the array. ``` fun Array<out Byte>.sum(): Int ``` ``` fun Array<out Short>.sum(): Int ``` ``` fun Array<out Int>.sum(): Int ``` ``` fun Array<out Long>.sum(): Long ``` ``` fun Array<out Float>.sum(): Float ``` ``` fun Array<out Double>.sum(): Double ``` ``` fun ByteArray.sum(): Int ``` ``` fun ShortArray.sum(): Int ``` ``` fun IntArray.sum(): Int ``` ``` fun LongArray.sum(): Long ``` ``` fun FloatArray.sum(): Float ``` ``` fun DoubleArray.sum(): Double ``` ``` fun Array<out UInt>.sum(): UInt ``` ``` fun Array<out ULong>.sum(): ULong ``` ``` fun Array<out UByte>.sum(): UInt ``` ``` fun Array<out UShort>.sum(): UInt ``` ``` fun UIntArray.sum(): UInt ``` ``` fun ULongArray.sum(): ULong ``` ``` fun UByteArray.sum(): UInt ``` ``` fun UShortArray.sum(): UInt ``` Returns the sum of all elements in the collection. ``` fun Iterable<Byte>.sum(): Int ``` ``` fun Iterable<Short>.sum(): Int ``` ``` fun Iterable<Int>.sum(): Int ``` ``` fun Iterable<Long>.sum(): Long ``` ``` fun Iterable<Float>.sum(): Float ``` ``` fun Iterable<Double>.sum(): Double ``` ``` fun Iterable<UInt>.sum(): UInt ``` ``` fun Iterable<ULong>.sum(): ULong ``` ``` fun Iterable<UByte>.sum(): UInt ``` ``` fun Iterable<UShort>.sum(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](sum-by) Returns the sum of all values produced by [selector](sum-by#kotlin.collections%24sumBy(kotlin.Array((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the array. ``` fun <T> Array<out T>.sumBy(selector: (T) -> Int): Int ``` ``` fun ByteArray.sumBy(selector: (Byte) -> Int): Int ``` ``` fun ShortArray.sumBy(selector: (Short) -> Int): Int ``` ``` fun IntArray.sumBy(selector: (Int) -> Int): Int ``` ``` fun LongArray.sumBy(selector: (Long) -> Int): Int ``` ``` fun FloatArray.sumBy(selector: (Float) -> Int): Int ``` ``` fun DoubleArray.sumBy(selector: (Double) -> Int): Int ``` ``` fun BooleanArray.sumBy(selector: (Boolean) -> Int): Int ``` ``` fun CharArray.sumBy(selector: (Char) -> Int): Int ``` ``` fun UIntArray.sumBy(selector: (UInt) -> UInt): UInt ``` ``` fun ULongArray.sumBy(selector: (ULong) -> UInt): UInt ``` ``` fun UByteArray.sumBy(selector: (UByte) -> UInt): UInt ``` ``` fun UShortArray.sumBy(selector: (UShort) -> UInt): UInt ``` Returns the sum of all values produced by [selector](sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](sum-by-double) Returns the sum of all values produced by [selector](sum-by-double#kotlin.collections%24sumByDouble(kotlin.Array((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <T> Array<out T>.sumByDouble(     selector: (T) -> Double ): Double ``` ``` fun ByteArray.sumByDouble(selector: (Byte) -> Double): Double ``` ``` fun ShortArray.sumByDouble(     selector: (Short) -> Double ): Double ``` ``` fun IntArray.sumByDouble(selector: (Int) -> Double): Double ``` ``` fun LongArray.sumByDouble(selector: (Long) -> Double): Double ``` ``` fun FloatArray.sumByDouble(     selector: (Float) -> Double ): Double ``` ``` fun DoubleArray.sumByDouble(     selector: (Double) -> Double ): Double ``` ``` fun BooleanArray.sumByDouble(     selector: (Boolean) -> Double ): Double ``` ``` fun CharArray.sumByDouble(selector: (Char) -> Double): Double ``` ``` fun UIntArray.sumByDouble(selector: (UInt) -> Double): Double ``` ``` fun ULongArray.sumByDouble(     selector: (ULong) -> Double ): Double ``` ``` fun UByteArray.sumByDouble(     selector: (UByte) -> Double ): Double ``` ``` fun UShortArray.sumByDouble(     selector: (UShort) -> Double ): Double ``` Returns the sum of all values produced by [selector](sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](sum-of) Returns the sum of all values produced by [selector](sum-of#kotlin.collections%24sumOf(kotlin.Array((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<out T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ByteArray.sumOf(selector: (Byte) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ShortArray.sumOf(selector: (Short) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun IntArray.sumOf(selector: (Int) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun LongArray.sumOf(selector: (Long) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun FloatArray.sumOf(selector: (Float) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun DoubleArray.sumOf(selector: (Double) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun BooleanArray.sumOf(selector: (Boolean) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharArray.sumOf(selector: (Char) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<out T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ByteArray.sumOf(selector: (Byte) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ShortArray.sumOf(selector: (Short) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun IntArray.sumOf(selector: (Int) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun LongArray.sumOf(selector: (Long) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun FloatArray.sumOf(selector: (Float) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun DoubleArray.sumOf(selector: (Double) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun BooleanArray.sumOf(selector: (Boolean) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharArray.sumOf(selector: (Char) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<out T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ByteArray.sumOf(selector: (Byte) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ShortArray.sumOf(selector: (Short) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun IntArray.sumOf(selector: (Int) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun LongArray.sumOf(selector: (Long) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun FloatArray.sumOf(selector: (Float) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun DoubleArray.sumOf(selector: (Double) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun BooleanArray.sumOf(selector: (Boolean) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharArray.sumOf(selector: (Char) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Array<out T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ByteArray.sumOf(selector: (Byte) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ShortArray.sumOf(selector: (Short) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun IntArray.sumOf(selector: (Int) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun LongArray.sumOf(selector: (Long) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun FloatArray.sumOf(selector: (Float) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun DoubleArray.sumOf(selector: (Double) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun BooleanArray.sumOf(selector: (Boolean) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun CharArray.sumOf(selector: (Char) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Array<out T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ByteArray.sumOf(selector: (Byte) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ShortArray.sumOf(selector: (Short) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun IntArray.sumOf(selector: (Int) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun LongArray.sumOf(selector: (Long) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun FloatArray.sumOf(selector: (Float) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun DoubleArray.sumOf(selector: (Double) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun BooleanArray.sumOf(selector: (Boolean) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun CharArray.sumOf(selector: (Char) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UIntArray.sumOf(selector: (UInt) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ULongArray.sumOf(selector: (ULong) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UByteArray.sumOf(selector: (UByte) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UShortArray.sumOf(selector: (UShort) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UIntArray.sumOf(selector: (UInt) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ULongArray.sumOf(selector: (ULong) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UByteArray.sumOf(selector: (UByte) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UShortArray.sumOf(selector: (UShort) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UIntArray.sumOf(selector: (UInt) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ULongArray.sumOf(selector: (ULong) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UByteArray.sumOf(selector: (UByte) -> Long): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun UShortArray.sumOf(selector: (UShort) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UIntArray.sumOf(selector: (UInt) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULongArray.sumOf(selector: (ULong) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UByteArray.sumOf(selector: (UByte) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UShortArray.sumOf(selector: (UShort) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UIntArray.sumOf(selector: (UInt) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULongArray.sumOf(selector: (ULong) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UByteArray.sumOf(selector: (UByte) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UShortArray.sumOf(selector: (UShort) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Array<out T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun ByteArray.sumOf(     selector: (Byte) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun ShortArray.sumOf(     selector: (Short) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun IntArray.sumOf(selector: (Int) -> BigDecimal): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun LongArray.sumOf(     selector: (Long) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun FloatArray.sumOf(     selector: (Float) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun DoubleArray.sumOf(     selector: (Double) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun BooleanArray.sumOf(     selector: (Boolean) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun CharArray.sumOf(     selector: (Char) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Array<out T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun ByteArray.sumOf(     selector: (Byte) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun ShortArray.sumOf(     selector: (Short) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun IntArray.sumOf(selector: (Int) -> BigInteger): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun LongArray.sumOf(     selector: (Long) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun FloatArray.sumOf(     selector: (Float) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun DoubleArray.sumOf(     selector: (Double) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun BooleanArray.sumOf(     selector: (Boolean) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun CharArray.sumOf(     selector: (Char) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun UIntArray.sumOf(     selector: (UInt) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun ULongArray.sumOf(     selector: (ULong) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun UByteArray.sumOf(     selector: (UByte) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun UShortArray.sumOf(     selector: (UShort) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun UIntArray.sumOf(     selector: (UInt) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun ULongArray.sumOf(     selector: (ULong) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun UByteArray.sumOf(     selector: (UByte) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` fun UShortArray.sumOf(     selector: (UShort) -> BigInteger ): BigInteger ``` Returns the sum of all values produced by [selector](sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <take> Returns a list containing first [n](take#kotlin.collections%24take(kotlin.Array((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Array<out T>.take(n: Int): List<T> ``` ``` fun ByteArray.take(n: Int): List<Byte> ``` ``` fun ShortArray.take(n: Int): List<Short> ``` ``` fun IntArray.take(n: Int): List<Int> ``` ``` fun LongArray.take(n: Int): List<Long> ``` ``` fun FloatArray.take(n: Int): List<Float> ``` ``` fun DoubleArray.take(n: Int): List<Double> ``` ``` fun BooleanArray.take(n: Int): List<Boolean> ``` ``` fun CharArray.take(n: Int): List<Char> ``` ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` ``` fun UIntArray.take(n: Int): List<UInt> ``` ``` fun ULongArray.take(n: Int): List<ULong> ``` ``` fun UByteArray.take(n: Int): List<UByte> ``` ``` fun UShortArray.take(n: Int): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](take-last) Returns a list containing last [n](take-last#kotlin.collections%24takeLast(kotlin.Array((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> Array<out T>.takeLast(n: Int): List<T> ``` ``` fun ByteArray.takeLast(n: Int): List<Byte> ``` ``` fun ShortArray.takeLast(n: Int): List<Short> ``` ``` fun IntArray.takeLast(n: Int): List<Int> ``` ``` fun LongArray.takeLast(n: Int): List<Long> ``` ``` fun FloatArray.takeLast(n: Int): List<Float> ``` ``` fun DoubleArray.takeLast(n: Int): List<Double> ``` ``` fun BooleanArray.takeLast(n: Int): List<Boolean> ``` ``` fun CharArray.takeLast(n: Int): List<Char> ``` ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` ``` fun UIntArray.takeLast(n: Int): List<UInt> ``` ``` fun ULongArray.takeLast(n: Int): List<ULong> ``` ``` fun UByteArray.takeLast(n: Int): List<UByte> ``` ``` fun UShortArray.takeLast(n: Int): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](take-last-while) Returns a list containing last elements satisfying the given [predicate](take-last-while#kotlin.collections%24takeLastWhile(kotlin.Array((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` fun ByteArray.takeLastWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` fun ShortArray.takeLastWhile(     predicate: (Short) -> Boolean ): List<Short> ``` ``` fun IntArray.takeLastWhile(     predicate: (Int) -> Boolean ): List<Int> ``` ``` fun LongArray.takeLastWhile(     predicate: (Long) -> Boolean ): List<Long> ``` ``` fun FloatArray.takeLastWhile(     predicate: (Float) -> Boolean ): List<Float> ``` ``` fun DoubleArray.takeLastWhile(     predicate: (Double) -> Boolean ): List<Double> ``` ``` fun BooleanArray.takeLastWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.takeLastWhile(     predicate: (Char) -> Boolean ): List<Char> ``` ``` fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` fun UIntArray.takeLastWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` fun ULongArray.takeLastWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun UByteArray.takeLastWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` fun UShortArray.takeLastWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](take-while) Returns a list containing first elements satisfying the given [predicate](take-while#kotlin.collections%24takeWhile(kotlin.Array((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` fun ByteArray.takeWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` fun ShortArray.takeWhile(     predicate: (Short) -> Boolean ): List<Short> ``` ``` fun IntArray.takeWhile(     predicate: (Int) -> Boolean ): List<Int> ``` ``` fun LongArray.takeWhile(     predicate: (Long) -> Boolean ): List<Long> ``` ``` fun FloatArray.takeWhile(     predicate: (Float) -> Boolean ): List<Float> ``` ``` fun DoubleArray.takeWhile(     predicate: (Double) -> Boolean ): List<Double> ``` ``` fun BooleanArray.takeWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` fun CharArray.takeWhile(     predicate: (Char) -> Boolean ): List<Char> ``` ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` fun UIntArray.takeWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` fun ULongArray.takeWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` fun UByteArray.takeWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` fun UShortArray.takeWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](to-boolean-array) Returns an array of Boolean containing all of the elements of this generic array. ``` fun Array<out Boolean>.toBooleanArray(): BooleanArray ``` Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](to-byte-array) Returns an array of Byte containing all of the elements of this generic array. ``` fun Array<out Byte>.toByteArray(): ByteArray ``` Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` Returns an array of type [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun UByteArray.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](to-char-array) Returns an array of Char containing all of the elements of this generic array. ``` fun Array<out Char>.toCharArray(): CharArray ``` Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](to-collection) Appends all elements to the given [destination](to-collection#kotlin.collections%24toCollection(kotlin.Array((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Array<out T>.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Byte>> ByteArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Short>> ShortArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Int>> IntArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Long>> LongArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Float>> FloatArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Double>> DoubleArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Boolean>> BooleanArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Char>> CharArray.toCollection(     destination: C ): C ``` ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](to-double-array) Returns an array of Double containing all of the elements of this generic array. ``` fun Array<out Double>.toDoubleArray(): DoubleArray ``` Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](to-float-array) Returns an array of Float containing all of the elements of this generic array. ``` fun Array<out Float>.toFloatArray(): FloatArray ``` Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](to-hash-set) Returns a new [HashSet](-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Array<out T>.toHashSet(): HashSet<T> ``` ``` fun ByteArray.toHashSet(): HashSet<Byte> ``` ``` fun ShortArray.toHashSet(): HashSet<Short> ``` ``` fun IntArray.toHashSet(): HashSet<Int> ``` ``` fun LongArray.toHashSet(): HashSet<Long> ``` ``` fun FloatArray.toHashSet(): HashSet<Float> ``` ``` fun DoubleArray.toHashSet(): HashSet<Double> ``` ``` fun BooleanArray.toHashSet(): HashSet<Boolean> ``` ``` fun CharArray.toHashSet(): HashSet<Char> ``` ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](to-int-array) Returns an array of Int containing all of the elements of this generic array. ``` fun Array<out Int>.toIntArray(): IntArray ``` Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` Returns an array of type [IntArray](../kotlin/-int-array/index#kotlin.IntArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun UIntArray.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](to-list) Returns a [List](-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Array<out T>.toList(): List<T> ``` ``` fun ByteArray.toList(): List<Byte> ``` ``` fun ShortArray.toList(): List<Short> ``` ``` fun IntArray.toList(): List<Int> ``` ``` fun LongArray.toList(): List<Long> ``` ``` fun FloatArray.toList(): List<Float> ``` ``` fun DoubleArray.toList(): List<Double> ``` ``` fun BooleanArray.toList(): List<Boolean> ``` ``` fun CharArray.toList(): List<Char> ``` ``` fun <T> Iterable<T>.toList(): List<T> ``` Returns a [List](-list/index#kotlin.collections.List) containing all key-value pairs. ``` fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](to-long-array) Returns an array of Long containing all of the elements of this generic array. ``` fun Array<out Long>.toLongArray(): LongArray ``` Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` Returns an array of type [LongArray](../kotlin/-long-array/index#kotlin.LongArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun ULongArray.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` Returns a new map containing all key-value pairs from the given array of pairs. ``` fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](to-map#kotlin.collections%24toMap(kotlin.Array((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given array of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Array<out Pair<K, V>>.toMap(     destination: M ): M ``` Returns a new map containing all key-value pairs from the given sequence of pairs. ``` fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](to-map#kotlin.collections%24toMap(kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given sequence of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.toMap(     destination: M ): M ``` Returns a new read-only map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMap(): Map<K, V> ``` Populates and returns the [destination](to-map#kotlin.collections%24toMap(kotlin.collections.Map((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given map. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](to-mutable-list) Returns a new [MutableList](-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun <T> any_array<T>.toMutableList(): MutableList<T> ``` Returns a new [MutableList](-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this collection. ``` fun <T> Iterable<T>.toMutableList(): MutableList<T> ``` ``` fun <T> Collection<T>.toMutableList(): MutableList<T> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMutableMap](to-mutable-map) Returns a new mutable map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](to-mutable-set) Returns a new [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given array. ``` fun <T> any_array<T>.toMutableSet(): MutableSet<T> ``` Returns a new [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toPair](to-pair) Converts entry to [Pair](../kotlin/-pair/index) with key being first component and value being second. ``` fun <K, V> Entry<K, V>.toPair(): Pair<K, V> ``` **Platform and version requirements:** JVM (1.0) #### [toProperties](to-properties) Converts this [Map](-map/index#kotlin.collections.Map) to a [Properties](https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html) object. ``` fun Map<String, String>.toProperties(): Properties ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](to-set) Returns a [Set](-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Array<out T>.toSet(): Set<T> ``` ``` fun ByteArray.toSet(): Set<Byte> ``` ``` fun ShortArray.toSet(): Set<Short> ``` ``` fun IntArray.toSet(): Set<Int> ``` ``` fun LongArray.toSet(): Set<Long> ``` ``` fun FloatArray.toSet(): Set<Float> ``` ``` fun DoubleArray.toSet(): Set<Double> ``` ``` fun BooleanArray.toSet(): Set<Boolean> ``` ``` fun CharArray.toSet(): Set<Char> ``` ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](to-short-array) Returns an array of Short containing all of the elements of this generic array. ``` fun Array<out Short>.toShortArray(): ShortArray ``` Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` Returns an array of type [ShortArray](../kotlin/-short-array/index#kotlin.ShortArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. ``` fun UShortArray.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedMap](to-sorted-map) Converts this [Map](-map/index#kotlin.collections.Map) to a [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to their natural sorting order. ``` fun <K : Comparable<K>, V> Map<out K, V>.toSortedMap(): SortedMap<K, V> ``` Converts this [Map](-map/index#kotlin.collections.Map) to a [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to the sorting order provided by the given [comparator](to-sorted-map#kotlin.collections%24toSortedMap(kotlin.collections.Map((kotlin.collections.toSortedMap.K,%20kotlin.collections.toSortedMap.V)),%20java.util.Comparator((kotlin.collections.toSortedMap.K)))/comparator). ``` fun <K, V> Map<out K, V>.toSortedMap(     comparator: Comparator<in K> ): SortedMap<K, V> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T : Comparable<T>> Array<out T>.toSortedSet(): SortedSet<T> ``` ``` fun ByteArray.toSortedSet(): SortedSet<Byte> ``` ``` fun ShortArray.toSortedSet(): SortedSet<Short> ``` ``` fun IntArray.toSortedSet(): SortedSet<Int> ``` ``` fun LongArray.toSortedSet(): SortedSet<Long> ``` ``` fun FloatArray.toSortedSet(): SortedSet<Float> ``` ``` fun DoubleArray.toSortedSet(): SortedSet<Double> ``` ``` fun BooleanArray.toSortedSet(): SortedSet<Boolean> ``` ``` fun CharArray.toSortedSet(): SortedSet<Char> ``` ``` fun <T> Array<out T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` ``` fun <T : Comparable<T>> Iterable<T>.toSortedSet(): SortedSet<T> ``` ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.0) #### [toString](to-string) Converts the contents of this byte array to a string using the specified [charset](to-string#kotlin.collections%24toString(kotlin.ByteArray,%20java.nio.charset.Charset)/charset). ``` fun ByteArray.toString(charset: Charset): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toTypedArray](to-typed-array) Returns a *typed* object array containing all of the elements of this primitive array. ``` fun UIntArray.toTypedArray(): Array<UInt> ``` ``` fun ULongArray.toTypedArray(): Array<ULong> ``` ``` fun UByteArray.toTypedArray(): Array<UByte> ``` ``` fun UShortArray.toTypedArray(): Array<UShort> ``` ``` fun ByteArray.toTypedArray(): Array<Byte> ``` ``` fun ShortArray.toTypedArray(): Array<Short> ``` ``` fun IntArray.toTypedArray(): Array<Int> ``` ``` fun LongArray.toTypedArray(): Array<Long> ``` ``` fun FloatArray.toTypedArray(): Array<Float> ``` ``` fun DoubleArray.toTypedArray(): Array<Double> ``` ``` fun BooleanArray.toTypedArray(): Array<Boolean> ``` ``` fun CharArray.toTypedArray(): Array<Char> ``` Returns a *typed* array containing all of the elements of this collection. ``` fun <T> Collection<T>.toTypedArray(): Array<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](to-u-byte-array) Returns an array of UByte containing all of the elements of this generic array. ``` fun Array<out UByte>.toUByteArray(): UByteArray ``` Returns an array of type [UByteArray](../kotlin/-u-byte-array/index), which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array. ``` fun ByteArray.toUByteArray(): UByteArray ``` Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](to-u-int-array) Returns an array of UInt containing all of the elements of this generic array. ``` fun Array<out UInt>.toUIntArray(): UIntArray ``` Returns an array of type [UIntArray](../kotlin/-u-int-array/index), which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array. ``` fun IntArray.toUIntArray(): UIntArray ``` Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](to-u-long-array) Returns an array of ULong containing all of the elements of this generic array. ``` fun Array<out ULong>.toULongArray(): ULongArray ``` Returns an array of type [ULongArray](../kotlin/-u-long-array/index), which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array. ``` fun LongArray.toULongArray(): ULongArray ``` Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](to-u-short-array) Returns an array of UShort containing all of the elements of this generic array. ``` fun Array<out UShort>.toUShortArray(): UShortArray ``` Returns an array of type [UShortArray](../kotlin/-u-short-array/index), which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array. ``` fun ShortArray.toUShortArray(): UShortArray ``` Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <union> Returns a set containing all distinct elements from both collections. ``` infix fun <T> Array<out T>.union(other: Iterable<T>): Set<T> ``` ``` infix fun ByteArray.union(other: Iterable<Byte>): Set<Byte> ``` ``` infix fun ShortArray.union(     other: Iterable<Short> ): Set<Short> ``` ``` infix fun IntArray.union(other: Iterable<Int>): Set<Int> ``` ``` infix fun LongArray.union(other: Iterable<Long>): Set<Long> ``` ``` infix fun FloatArray.union(     other: Iterable<Float> ): Set<Float> ``` ``` infix fun DoubleArray.union(     other: Iterable<Double> ): Set<Double> ``` ``` infix fun BooleanArray.union(     other: Iterable<Boolean> ): Set<Boolean> ``` ``` infix fun CharArray.union(other: Iterable<Char>): Set<Char> ``` ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <unzip> Returns a pair of lists, where *first* list is built from the first values of each pair from this array, *second* list is built from the second values of each pair from this array. ``` fun <T, R> Array<out Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <windowed> Returns a list of snapshots of the window of the given [size](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withDefault](with-default) Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue](with-default#kotlin.collections%24withDefault(kotlin.collections.Map((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> Map<K, V>.withDefault(     defaultValue: (key: K) -> V ): Map<K, V> ``` Returns a wrapper of this mutable map, having the implicit default value provided with the specified function [defaultValue](with-default#kotlin.collections%24withDefault(kotlin.collections.MutableMap((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> MutableMap<K, V>.withDefault(     defaultValue: (key: K) -> V ): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](with-index) Returns a lazy [Iterable](-iterable/index#kotlin.collections.Iterable) that wraps each element of the original array into an [IndexedValue](-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Array<out T>.withIndex(): Iterable<IndexedValue<T>> ``` ``` fun ByteArray.withIndex(): Iterable<IndexedValue<Byte>> ``` ``` fun ShortArray.withIndex(): Iterable<IndexedValue<Short>> ``` ``` fun IntArray.withIndex(): Iterable<IndexedValue<Int>> ``` ``` fun LongArray.withIndex(): Iterable<IndexedValue<Long>> ``` ``` fun FloatArray.withIndex(): Iterable<IndexedValue<Float>> ``` ``` fun DoubleArray.withIndex(): Iterable<IndexedValue<Double>> ``` ``` fun BooleanArray.withIndex(): Iterable<IndexedValue<Boolean>> ``` ``` fun CharArray.withIndex(): Iterable<IndexedValue<Char>> ``` ``` fun UIntArray.withIndex(): Iterable<IndexedValue<UInt>> ``` ``` fun ULongArray.withIndex(): Iterable<IndexedValue<ULong>> ``` ``` fun UByteArray.withIndex(): Iterable<IndexedValue<UByte>> ``` ``` fun UShortArray.withIndex(): Iterable<IndexedValue<UShort>> ``` Returns a lazy [Iterable](-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` Returns an [Iterator](-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <zip> Returns a list of pairs built from the elements of `this` array and the [other](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Array<out T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` ``` infix fun <R> ByteArray.zip(     other: Array<out R> ): List<Pair<Byte, R>> ``` ``` infix fun <R> ShortArray.zip(     other: Array<out R> ): List<Pair<Short, R>> ``` ``` infix fun <R> IntArray.zip(     other: Array<out R> ): List<Pair<Int, R>> ``` ``` infix fun <R> LongArray.zip(     other: Array<out R> ): List<Pair<Long, R>> ``` ``` infix fun <R> FloatArray.zip(     other: Array<out R> ): List<Pair<Float, R>> ``` ``` infix fun <R> DoubleArray.zip(     other: Array<out R> ): List<Pair<Double, R>> ``` ``` infix fun <R> BooleanArray.zip(     other: Array<out R> ): List<Pair<Boolean, R>> ``` ``` infix fun <R> CharArray.zip(     other: Array<out R> ): List<Pair<Char, R>> ``` ``` infix fun ByteArray.zip(     other: ByteArray ): List<Pair<Byte, Byte>> ``` ``` infix fun ShortArray.zip(     other: ShortArray ): List<Pair<Short, Short>> ``` ``` infix fun IntArray.zip(other: IntArray): List<Pair<Int, Int>> ``` ``` infix fun LongArray.zip(     other: LongArray ): List<Pair<Long, Long>> ``` ``` infix fun FloatArray.zip(     other: FloatArray ): List<Pair<Float, Float>> ``` ``` infix fun DoubleArray.zip(     other: DoubleArray ): List<Pair<Double, Double>> ``` ``` infix fun BooleanArray.zip(     other: BooleanArray ): List<Pair<Boolean, Boolean>> ``` ``` infix fun CharArray.zip(     other: CharArray ): List<Pair<Char, Char>> ``` ``` infix fun <R> UIntArray.zip(     other: Array<out R> ): List<Pair<UInt, R>> ``` ``` infix fun <R> ULongArray.zip(     other: Array<out R> ): List<Pair<ULong, R>> ``` ``` infix fun <R> UByteArray.zip(     other: Array<out R> ): List<Pair<UByte, R>> ``` ``` infix fun <R> UShortArray.zip(     other: Array<out R> ): List<Pair<UShort, R>> ``` ``` infix fun UIntArray.zip(     other: UIntArray ): List<Pair<UInt, UInt>> ``` ``` infix fun ULongArray.zip(     other: ULongArray ): List<Pair<ULong, ULong>> ``` ``` infix fun UByteArray.zip(     other: UByteArray ): List<Pair<UByte, UByte>> ``` ``` infix fun UShortArray.zip(     other: UShortArray ): List<Pair<UShort, UShort>> ``` Returns a list of values built from the elements of `this` array and the [other](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Array<out T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` ``` fun <R, V> ByteArray.zip(     other: Array<out R>,     transform: (a: Byte, b: R) -> V ): List<V> ``` ``` fun <R, V> ShortArray.zip(     other: Array<out R>,     transform: (a: Short, b: R) -> V ): List<V> ``` ``` fun <R, V> IntArray.zip(     other: Array<out R>,     transform: (a: Int, b: R) -> V ): List<V> ``` ``` fun <R, V> LongArray.zip(     other: Array<out R>,     transform: (a: Long, b: R) -> V ): List<V> ``` ``` fun <R, V> FloatArray.zip(     other: Array<out R>,     transform: (a: Float, b: R) -> V ): List<V> ``` ``` fun <R, V> DoubleArray.zip(     other: Array<out R>,     transform: (a: Double, b: R) -> V ): List<V> ``` ``` fun <R, V> BooleanArray.zip(     other: Array<out R>,     transform: (a: Boolean, b: R) -> V ): List<V> ``` ``` fun <R, V> CharArray.zip(     other: Array<out R>,     transform: (a: Char, b: R) -> V ): List<V> ``` ``` fun <R, V> UIntArray.zip(     other: Array<out R>,     transform: (a: UInt, b: R) -> V ): List<V> ``` ``` fun <R, V> ULongArray.zip(     other: Array<out R>,     transform: (a: ULong, b: R) -> V ): List<V> ``` ``` fun <R, V> UByteArray.zip(     other: Array<out R>,     transform: (a: UByte, b: R) -> V ): List<V> ``` ``` fun <R, V> UShortArray.zip(     other: Array<out R>,     transform: (a: UShort, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Array<out T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` ``` infix fun <R> ByteArray.zip(     other: Iterable<R> ): List<Pair<Byte, R>> ``` ``` infix fun <R> ShortArray.zip(     other: Iterable<R> ): List<Pair<Short, R>> ``` ``` infix fun <R> IntArray.zip(     other: Iterable<R> ): List<Pair<Int, R>> ``` ``` infix fun <R> LongArray.zip(     other: Iterable<R> ): List<Pair<Long, R>> ``` ``` infix fun <R> FloatArray.zip(     other: Iterable<R> ): List<Pair<Float, R>> ``` ``` infix fun <R> DoubleArray.zip(     other: Iterable<R> ): List<Pair<Double, R>> ``` ``` infix fun <R> BooleanArray.zip(     other: Iterable<R> ): List<Pair<Boolean, R>> ``` ``` infix fun <R> CharArray.zip(     other: Iterable<R> ): List<Pair<Char, R>> ``` ``` infix fun <R> UIntArray.zip(     other: Iterable<R> ): List<Pair<UInt, R>> ``` ``` infix fun <R> ULongArray.zip(     other: Iterable<R> ): List<Pair<ULong, R>> ``` ``` infix fun <R> UByteArray.zip(     other: Iterable<R> ): List<Pair<UByte, R>> ``` ``` infix fun <R> UShortArray.zip(     other: Iterable<R> ): List<Pair<UShort, R>> ``` Returns a list of values built from the elements of `this` array and the [other](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Array<out T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` ``` fun <R, V> ByteArray.zip(     other: Iterable<R>,     transform: (a: Byte, b: R) -> V ): List<V> ``` ``` fun <R, V> ShortArray.zip(     other: Iterable<R>,     transform: (a: Short, b: R) -> V ): List<V> ``` ``` fun <R, V> IntArray.zip(     other: Iterable<R>,     transform: (a: Int, b: R) -> V ): List<V> ``` ``` fun <R, V> LongArray.zip(     other: Iterable<R>,     transform: (a: Long, b: R) -> V ): List<V> ``` ``` fun <R, V> FloatArray.zip(     other: Iterable<R>,     transform: (a: Float, b: R) -> V ): List<V> ``` ``` fun <R, V> DoubleArray.zip(     other: Iterable<R>,     transform: (a: Double, b: R) -> V ): List<V> ``` ``` fun <R, V> BooleanArray.zip(     other: Iterable<R>,     transform: (a: Boolean, b: R) -> V ): List<V> ``` ``` fun <R, V> CharArray.zip(     other: Iterable<R>,     transform: (a: Char, b: R) -> V ): List<V> ``` ``` fun <R, V> UIntArray.zip(     other: Iterable<R>,     transform: (a: UInt, b: R) -> V ): List<V> ``` ``` fun <R, V> ULongArray.zip(     other: Iterable<R>,     transform: (a: ULong, b: R) -> V ): List<V> ``` ``` fun <R, V> UByteArray.zip(     other: Iterable<R>,     transform: (a: UByte, b: R) -> V ): List<V> ``` ``` fun <R, V> UShortArray.zip(     other: Iterable<R>,     transform: (a: UShort, b: R) -> V ): List<V> ``` Returns a list of values built from the elements of `this` array and the [other](zip#kotlin.collections%24zip(kotlin.ByteArray,%20kotlin.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.ByteArray,%20kotlin.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> ByteArray.zip(     other: ByteArray,     transform: (a: Byte, b: Byte) -> V ): List<V> ``` ``` fun <V> ShortArray.zip(     other: ShortArray,     transform: (a: Short, b: Short) -> V ): List<V> ``` ``` fun <V> IntArray.zip(     other: IntArray,     transform: (a: Int, b: Int) -> V ): List<V> ``` ``` fun <V> LongArray.zip(     other: LongArray,     transform: (a: Long, b: Long) -> V ): List<V> ``` ``` fun <V> FloatArray.zip(     other: FloatArray,     transform: (a: Float, b: Float) -> V ): List<V> ``` ``` fun <V> DoubleArray.zip(     other: DoubleArray,     transform: (a: Double, b: Double) -> V ): List<V> ``` ``` fun <V> BooleanArray.zip(     other: BooleanArray,     transform: (a: Boolean, b: Boolean) -> V ): List<V> ``` ``` fun <V> CharArray.zip(     other: CharArray,     transform: (a: Char, b: Char) -> V ): List<V> ``` ``` fun <V> UIntArray.zip(     other: UIntArray,     transform: (a: UInt, b: UInt) -> V ): List<V> ``` ``` fun <V> ULongArray.zip(     other: ULongArray,     transform: (a: ULong, b: ULong) -> V ): List<V> ``` ``` fun <V> UByteArray.zip(     other: UByteArray,     transform: (a: UByte, b: UByte) -> V ): List<V> ``` ``` fun <V> UShortArray.zip(     other: UShortArray,     transform: (a: UShort, b: UShort) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and the [other](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ```
programming_docs
kotlin associateWith associateWith ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [associateWith](associate-with) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V> Array<out K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` ``` inline fun <V> ByteArray.associateWith(     valueSelector: (Byte) -> V ): Map<Byte, V> ``` ``` inline fun <V> ShortArray.associateWith(     valueSelector: (Short) -> V ): Map<Short, V> ``` ``` inline fun <V> IntArray.associateWith(     valueSelector: (Int) -> V ): Map<Int, V> ``` ``` inline fun <V> LongArray.associateWith(     valueSelector: (Long) -> V ): Map<Long, V> ``` ``` inline fun <V> FloatArray.associateWith(     valueSelector: (Float) -> V ): Map<Float, V> ``` ``` inline fun <V> DoubleArray.associateWith(     valueSelector: (Double) -> V ): Map<Double, V> ``` ``` inline fun <V> BooleanArray.associateWith(     valueSelector: (Boolean) -> V ): Map<Boolean, V> ``` ``` inline fun <V> CharArray.associateWith(     valueSelector: (Char) -> V ): Map<Char, V> ``` ``` @ExperimentalUnsignedTypes inline fun <V> UIntArray.associateWith(     valueSelector: (UInt) -> V ): Map<UInt, V> ``` ``` @ExperimentalUnsignedTypes inline fun <V> ULongArray.associateWith(     valueSelector: (ULong) -> V ): Map<ULong, V> ``` ``` @ExperimentalUnsignedTypes inline fun <V> UByteArray.associateWith(     valueSelector: (UByte) -> V ): Map<UByte, V> ``` ``` @ExperimentalUnsignedTypes inline fun <V> UShortArray.associateWith(     valueSelector: (UShort) -> V ): Map<UShort, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) where keys are elements from the given array and values are produced by the [valueSelector](associate-with#kotlin.collections%24associateWith(kotlin.Array((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. If any two elements are equal, the last one gets added to the map. The returned map preserves the entry iteration order of the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val withLength = words.associateWith { it.length } println(withLength.keys) // [a, abc, ab, def, abcd] println(withLength.values) // [1, 3, 2, 3, 4] //sampleEnd } ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. If any two elements are equal, the last one gets added to the map. The returned map preserves the entry iteration order of the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val withLength = words.associateWith { it.length } println(withLength.keys) // [a, abc, ab, def, abcd] println(withLength.values) // [1, 3, 2, 3, 4] //sampleEnd } ``` kotlin orEmpty orEmpty ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [orEmpty](or-empty) **Platform and version requirements:** JVM (1.0) ``` fun <reified T> Array<out T>?.orEmpty(): Array<out T> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> Array<out T>?.orEmpty(): Array<out T> ``` Returns the array if it's not `null`, or an empty array otherwise. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nullArray: Array<Any>? = null println(nullArray.orEmpty().contentToString()) // [] val array: Array<Char>? = arrayOf('a', 'b', 'c') println(array.orEmpty().contentToString()) // [a, b, c] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Collection<T>?.orEmpty(): Collection<T> ``` Returns this Collection if it's not `null` and the empty list otherwise. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nullCollection: Collection<Any>? = null println(nullCollection.orEmpty()) // [] val collection: Collection<Char>? = listOf('a', 'b', 'c') println(collection.orEmpty()) // [a, b, c] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>?.orEmpty(): List<T> ``` Returns this List if it's not `null` and the empty list otherwise. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nullList: List<Any>? = null println(nullList.orEmpty()) // [] val list: List<Char>? = listOf('a', 'b', 'c') println(list.orEmpty()) // [a, b, c] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> ``` Returns the [Map](-map/index#kotlin.collections.Map) if its not `null`, or the empty [Map](-map/index#kotlin.collections.Map) otherwise. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val nullMap: Map<String, Any>? = null println(nullMap.orEmpty()) // {} val map: Map<Char, Int>? = mapOf('a' to 1, 'b' to 2, 'c' to 3) println(map.orEmpty()) // {a=1, b=2, c=3} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Set<T>?.orEmpty(): Set<T> ``` Returns this Set if it's not `null` and the empty set otherwise. kotlin linkedStringMapOf linkedStringMapOf ================= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [linkedStringMapOf](linked-string-map-of) **Platform and version requirements:** JS (1.1) ``` fun <V> linkedStringMapOf(     vararg pairs: Pair<String, V> ): LinkedHashMap<String, V> ``` Constructs the specialized implementation of [LinkedHashMap](-linked-hash-map/index#kotlin.collections.LinkedHashMap) with String keys, which stores the keys as properties of JS object without hashing them. kotlin onEach onEach ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [onEach](on-each) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Array<out T>.onEach(     action: (T) -> Unit ): Array<out T> ``` ``` inline fun ByteArray.onEach(     action: (Byte) -> Unit ): ByteArray ``` ``` inline fun ShortArray.onEach(     action: (Short) -> Unit ): ShortArray ``` ``` inline fun IntArray.onEach(action: (Int) -> Unit): IntArray ``` ``` inline fun LongArray.onEach(     action: (Long) -> Unit ): LongArray ``` ``` inline fun FloatArray.onEach(     action: (Float) -> Unit ): FloatArray ``` ``` inline fun DoubleArray.onEach(     action: (Double) -> Unit ): DoubleArray ``` ``` inline fun BooleanArray.onEach(     action: (Boolean) -> Unit ): BooleanArray ``` ``` inline fun CharArray.onEach(     action: (Char) -> Unit ): CharArray ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.onEach(     action: (UInt) -> Unit ): UIntArray ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.onEach(     action: (ULong) -> Unit ): ULongArray ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.onEach(     action: (UByte) -> Unit ): UByteArray ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.onEach(     action: (UShort) -> Unit ): UShortArray ``` Performs the given [action](on-each#kotlin.collections%24onEach(kotlin.Array((kotlin.collections.onEach.T)),%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, C : Iterable<T>> C.onEach(     action: (T) -> Unit ): C ``` Performs the given [action](on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <K, V, M : Map<out K, V>> M.onEach(     action: (Entry<K, V>) -> Unit ): M ``` Performs the given [action](on-each#kotlin.collections%24onEach(kotlin.collections.onEach.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.onEach.K,%20kotlin.collections.onEach.V)),%20kotlin.Unit)))/action) on each entry and returns the map itself afterwards. kotlin setValue setValue ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [setValue](set-value) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <V> MutableMap<in String, in V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` Stores the value of the property for the given object in this mutable map. Parameters ---------- `thisRef` - the object for which the value is requested (not used). `property` - the metadata for the property, used to get the name of property and store the value associated with that name in the map. `value` - the value to set. kotlin asUByteArray asUByteArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asUByteArray](as-u-byte-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ByteArray.asUByteArray(): UByteArray ``` Returns an array of type [UByteArray](../kotlin/-u-byte-array/index), which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array. kotlin scan scan ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <scan> **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Array<out T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` ``` inline fun <R> ByteArray.scan(     initial: R,     operation: (acc: R, Byte) -> R ): List<R> ``` ``` inline fun <R> ShortArray.scan(     initial: R,     operation: (acc: R, Short) -> R ): List<R> ``` ``` inline fun <R> IntArray.scan(     initial: R,     operation: (acc: R, Int) -> R ): List<R> ``` ``` inline fun <R> LongArray.scan(     initial: R,     operation: (acc: R, Long) -> R ): List<R> ``` ``` inline fun <R> FloatArray.scan(     initial: R,     operation: (acc: R, Float) -> R ): List<R> ``` ``` inline fun <R> DoubleArray.scan(     initial: R,     operation: (acc: R, Double) -> R ): List<R> ``` ``` inline fun <R> BooleanArray.scan(     initial: R,     operation: (acc: R, Boolean) -> R ): List<R> ``` ``` inline fun <R> CharArray.scan(     initial: R,     operation: (acc: R, Char) -> R ): List<R> ``` ``` inline fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.scan(     initial: R,     operation: (acc: R, UInt) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.scan(     initial: R,     operation: (acc: R, ULong) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.scan(     initial: R,     operation: (acc: R, UByte) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.scan(     initial: R,     operation: (acc: R, UShort) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](scan#kotlin.collections%24scan(kotlin.Array((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](scan#kotlin.collections%24scan(kotlin.Array((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. Note that `acc` value passed to [operation](scan#kotlin.collections%24scan(kotlin.Array((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.scan("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.scanIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().scan("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. kotlin asUShortArray asUShortArray ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asUShortArray](as-u-short-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ShortArray.asUShortArray(): UShortArray ``` Returns an array of type [UShortArray](../kotlin/-u-short-array/index), which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array. kotlin getOrDefault getOrDefault ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [getOrDefault](get-or-default) **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun <K, V> Map<out K, V>.getOrDefault(     key: K,     defaultValue: V ): V ``` Returns the value to which the specified key is mapped, or [defaultValue](get-or-default#kotlin.collections%24getOrDefault(kotlin.collections.Map((kotlin.collections.getOrDefault.K,%20kotlin.collections.getOrDefault.V)),%20kotlin.collections.getOrDefault.K,%20kotlin.collections.getOrDefault.V)/defaultValue) if this map contains no mapping for the key. kotlin lastOrNull lastOrNull ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [lastOrNull](last-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.lastOrNull(): T? ``` ``` fun ByteArray.lastOrNull(): Byte? ``` ``` fun ShortArray.lastOrNull(): Short? ``` ``` fun IntArray.lastOrNull(): Int? ``` ``` fun LongArray.lastOrNull(): Long? ``` ``` fun FloatArray.lastOrNull(): Float? ``` ``` fun DoubleArray.lastOrNull(): Double? ``` ``` fun BooleanArray.lastOrNull(): Boolean? ``` ``` fun CharArray.lastOrNull(): Char? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.lastOrNull(): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.lastOrNull(): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.lastOrNull(): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.lastOrNull(): UShort? ``` Returns the last element, or `null` if the array is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.lastOrNull(     predicate: (T) -> Boolean ): T? ``` ``` inline fun ByteArray.lastOrNull(     predicate: (Byte) -> Boolean ): Byte? ``` ``` inline fun ShortArray.lastOrNull(     predicate: (Short) -> Boolean ): Short? ``` ``` inline fun IntArray.lastOrNull(     predicate: (Int) -> Boolean ): Int? ``` ``` inline fun LongArray.lastOrNull(     predicate: (Long) -> Boolean ): Long? ``` ``` inline fun FloatArray.lastOrNull(     predicate: (Float) -> Boolean ): Float? ``` ``` inline fun DoubleArray.lastOrNull(     predicate: (Double) -> Boolean ): Double? ``` ``` inline fun BooleanArray.lastOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.lastOrNull(     predicate: (Char) -> Boolean ): Char? ``` ``` inline fun <T> Iterable<T>.lastOrNull(     predicate: (T) -> Boolean ): T? ``` ``` inline fun <T> List<T>.lastOrNull(     predicate: (T) -> Boolean ): T? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.lastOrNull(     predicate: (UInt) -> Boolean ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.lastOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.lastOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.lastOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` Returns the last element matching the given [predicate](last-or-null#kotlin.collections%24lastOrNull(kotlin.Array((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element, or `null` if the collection is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.lastOrNull(): T? ``` Returns the last element, or `null` if the list is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` kotlin mapIndexedTo mapIndexedTo ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapIndexedTo](map-indexed-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, C : MutableCollection<in R>> Array<out T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> ByteArray.mapIndexedTo(     destination: C,     transform: (index: Int, Byte) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> ShortArray.mapIndexedTo(     destination: C,     transform: (index: Int, Short) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> IntArray.mapIndexedTo(     destination: C,     transform: (index: Int, Int) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> LongArray.mapIndexedTo(     destination: C,     transform: (index: Int, Long) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> FloatArray.mapIndexedTo(     destination: C,     transform: (index: Int, Float) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> DoubleArray.mapIndexedTo(     destination: C,     transform: (index: Int, Double) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> BooleanArray.mapIndexedTo(     destination: C,     transform: (index: Int, Boolean) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> CharArray.mapIndexedTo(     destination: C,     transform: (index: Int, Char) -> R ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UIntArray.mapIndexedTo(     destination: C,     transform: (index: Int, UInt) -> R ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> ULongArray.mapIndexedTo(     destination: C,     transform: (index: Int, ULong) -> R ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UByteArray.mapIndexedTo(     destination: C,     transform: (index: Int, UByte) -> R ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UShortArray.mapIndexedTo(     destination: C,     transform: (index: Int, UShort) -> R ): C ``` Applies the given [transform](map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.Array((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original array and appends the results to the given [destination](map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.Array((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` Applies the given [transform](map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element.
programming_docs
kotlin maxWithOrNull maxWithOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxWithOrNull](max-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<out T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` ``` fun ByteArray.maxWithOrNull(     comparator: Comparator<in Byte> ): Byte? ``` ``` fun ShortArray.maxWithOrNull(     comparator: Comparator<in Short> ): Short? ``` ``` fun IntArray.maxWithOrNull(     comparator: Comparator<in Int> ): Int? ``` ``` fun LongArray.maxWithOrNull(     comparator: Comparator<in Long> ): Long? ``` ``` fun FloatArray.maxWithOrNull(     comparator: Comparator<in Float> ): Float? ``` ``` fun DoubleArray.maxWithOrNull(     comparator: Comparator<in Double> ): Double? ``` ``` fun BooleanArray.maxWithOrNull(     comparator: Comparator<in Boolean> ): Boolean? ``` ``` fun CharArray.maxWithOrNull(     comparator: Comparator<in Char> ): Char? ``` ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.maxWithOrNull(     comparator: Comparator<in UInt> ): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.maxWithOrNull(     comparator: Comparator<in ULong> ): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.maxWithOrNull(     comparator: Comparator<in UByte> ): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.maxWithOrNull(     comparator: Comparator<in UShort> ): UShort? ``` Returns the first element having the largest value according to the provided [comparator](max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.Array((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <K, V> Map<out K, V>.maxWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` Returns the first entry having the largest value according to the provided [comparator](max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Map((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)))))/comparator) or `null` if there are no entries. kotlin toProperties toProperties ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toProperties](to-properties) **Platform and version requirements:** JVM (1.0) ``` fun Map<String, String>.toProperties(): Properties ``` Converts this [Map](-map/index#kotlin.collections.Map) to a [Properties](https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html) object. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mapOf("x" to "value A", "y" to "value B") val props = map.toProperties() println(props.getProperty("x")) // value A println(props.getProperty("y", "fail")) // value B println(props.getProperty("z", "fail")) // fail //sampleEnd } ``` kotlin forEachIndexed forEachIndexed ============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [forEachIndexed](for-each-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` ``` inline fun ByteArray.forEachIndexed(     action: (index: Int, Byte) -> Unit) ``` ``` inline fun ShortArray.forEachIndexed(     action: (index: Int, Short) -> Unit) ``` ``` inline fun IntArray.forEachIndexed(     action: (index: Int, Int) -> Unit) ``` ``` inline fun LongArray.forEachIndexed(     action: (index: Int, Long) -> Unit) ``` ``` inline fun FloatArray.forEachIndexed(     action: (index: Int, Float) -> Unit) ``` ``` inline fun DoubleArray.forEachIndexed(     action: (index: Int, Double) -> Unit) ``` ``` inline fun BooleanArray.forEachIndexed(     action: (index: Int, Boolean) -> Unit) ``` ``` inline fun CharArray.forEachIndexed(     action: (index: Int, Char) -> Unit) ``` ``` inline fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.forEachIndexed(     action: (index: Int, UInt) -> Unit) ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.forEachIndexed(     action: (index: Int, ULong) -> Unit) ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.forEachIndexed(     action: (index: Int, UByte) -> Unit) ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.forEachIndexed(     action: (index: Int, UShort) -> Unit) ``` Performs the given [action](for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.Array((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. Parameters ---------- `action` - function that takes the index of an element and the element itself and performs the action on the element. kotlin filterIndexed filterIndexed ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterIndexed](filter-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` ``` inline fun ByteArray.filterIndexed(     predicate: (index: Int, Byte) -> Boolean ): List<Byte> ``` ``` inline fun ShortArray.filterIndexed(     predicate: (index: Int, Short) -> Boolean ): List<Short> ``` ``` inline fun IntArray.filterIndexed(     predicate: (index: Int, Int) -> Boolean ): List<Int> ``` ``` inline fun LongArray.filterIndexed(     predicate: (index: Int, Long) -> Boolean ): List<Long> ``` ``` inline fun FloatArray.filterIndexed(     predicate: (index: Int, Float) -> Boolean ): List<Float> ``` ``` inline fun DoubleArray.filterIndexed(     predicate: (index: Int, Double) -> Boolean ): List<Double> ``` ``` inline fun BooleanArray.filterIndexed(     predicate: (index: Int, Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.filterIndexed(     predicate: (index: Int, Char) -> Boolean ): List<Char> ``` ``` inline fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.filterIndexed(     predicate: (index: Int, UInt) -> Boolean ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.filterIndexed(     predicate: (index: Int, ULong) -> Boolean ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.filterIndexed(     predicate: (index: Int, UByte) -> Boolean ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.filterIndexed(     predicate: (index: Int, UShort) -> Boolean ): List<UShort> ``` Returns a list containing only elements matching the given [predicate](filter-indexed#kotlin.collections%24filterIndexed(kotlin.Array((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(0, 1, 2, 3, 4, 8, 6) val numbersOnSameIndexAsValue = numbers.filterIndexed { index, i -> index == i } println(numbersOnSameIndexAsValue) // [0, 1, 2, 3, 4, 6] //sampleEnd } ``` Parameters ---------- `predicate` - function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element. kotlin sortedByDescending sortedByDescending ================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedByDescending](sorted-by-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Comparable<R>> Array<out T>.sortedByDescending(     crossinline selector: (T) -> R? ): List<T> ``` ``` inline fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     crossinline selector: (T) -> R? ): List<T> ``` Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.Array((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R : Comparable<R>> ByteArray.sortedByDescending(     crossinline selector: (Byte) -> R? ): List<Byte> ``` ``` inline fun <R : Comparable<R>> ShortArray.sortedByDescending(     crossinline selector: (Short) -> R? ): List<Short> ``` ``` inline fun <R : Comparable<R>> IntArray.sortedByDescending(     crossinline selector: (Int) -> R? ): List<Int> ``` ``` inline fun <R : Comparable<R>> LongArray.sortedByDescending(     crossinline selector: (Long) -> R? ): List<Long> ``` ``` inline fun <R : Comparable<R>> FloatArray.sortedByDescending(     crossinline selector: (Float) -> R? ): List<Float> ``` ``` inline fun <R : Comparable<R>> DoubleArray.sortedByDescending(     crossinline selector: (Double) -> R? ): List<Double> ``` ``` inline fun <R : Comparable<R>> BooleanArray.sortedByDescending(     crossinline selector: (Boolean) -> R? ): List<Boolean> ``` ``` inline fun <R : Comparable<R>> CharArray.sortedByDescending(     crossinline selector: (Char) -> R? ): List<Char> ``` Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.sortedByDescending.R?)))/selector) function. kotlin shuffle shuffle ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <shuffle> **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<T>.shuffle() ``` ``` fun ByteArray.shuffle() ``` ``` fun ShortArray.shuffle() ``` ``` fun IntArray.shuffle() ``` ``` fun LongArray.shuffle() ``` ``` fun FloatArray.shuffle() ``` ``` fun DoubleArray.shuffle() ``` ``` fun BooleanArray.shuffle() ``` ``` fun CharArray.shuffle() ``` ``` @ExperimentalUnsignedTypes fun UIntArray.shuffle() ``` ``` @ExperimentalUnsignedTypes fun ULongArray.shuffle() ``` ``` @ExperimentalUnsignedTypes fun UByteArray.shuffle() ``` ``` @ExperimentalUnsignedTypes fun UShortArray.shuffle() ``` Randomly shuffles elements in this array in-place. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<T>.shuffle(random: Random) ``` ``` fun ByteArray.shuffle(random: Random) ``` ``` fun ShortArray.shuffle(random: Random) ``` ``` fun IntArray.shuffle(random: Random) ``` ``` fun LongArray.shuffle(random: Random) ``` ``` fun FloatArray.shuffle(random: Random) ``` ``` fun DoubleArray.shuffle(random: Random) ``` ``` fun BooleanArray.shuffle(random: Random) ``` ``` fun CharArray.shuffle(random: Random) ``` ``` @ExperimentalUnsignedTypes fun UIntArray.shuffle(     random: Random) ``` ``` @ExperimentalUnsignedTypes fun ULongArray.shuffle(     random: Random) ``` ``` @ExperimentalUnsignedTypes fun UByteArray.shuffle(     random: Random) ``` ``` @ExperimentalUnsignedTypes fun UShortArray.shuffle(     random: Random) ``` Randomly shuffles elements in this array in-place using the specified [random](shuffle#kotlin.collections%24shuffle(kotlin.Array((kotlin.collections.shuffle.T)),%20kotlin.random.Random)/random) instance as the source of randomness. See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates\_shuffle#The\_modern\_algorithm **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> MutableList<T>.shuffle(random: Random) ``` Randomly shuffles elements in this list in-place using the specified [random](shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20kotlin.random.Random)/random) instance as the source of randomness. See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates\_shuffle#The\_modern\_algorithm **Platform and version requirements:** JVM (1.2), JS (1.2) ``` fun <T> MutableList<T>.shuffle() ``` ##### For JVM Randomly shuffles elements in this mutable list. ##### For JS Randomly shuffles elements in this list. See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates\_shuffle#The\_modern\_algorithm **Platform and version requirements:** JVM (1.2) ``` fun <T> MutableList<T>.shuffle(random: Random) ``` Randomly shuffles elements in this mutable list using the specified [random](shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20java.util.Random)/random) instance as the source of randomness. kotlin sliceArray sliceArray ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sliceArray](slice-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<T>.sliceArray(     indices: Collection<Int> ): Array<T> ``` ``` fun ByteArray.sliceArray(indices: Collection<Int>): ByteArray ``` ``` fun ShortArray.sliceArray(     indices: Collection<Int> ): ShortArray ``` ``` fun IntArray.sliceArray(indices: Collection<Int>): IntArray ``` ``` fun LongArray.sliceArray(indices: Collection<Int>): LongArray ``` ``` fun FloatArray.sliceArray(     indices: Collection<Int> ): FloatArray ``` ``` fun DoubleArray.sliceArray(     indices: Collection<Int> ): DoubleArray ``` ``` fun BooleanArray.sliceArray(     indices: Collection<Int> ): BooleanArray ``` ``` fun CharArray.sliceArray(indices: Collection<Int>): CharArray ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sliceArray(     indices: Collection<Int> ): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sliceArray(     indices: Collection<Int> ): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sliceArray(     indices: Collection<Int> ): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sliceArray(     indices: Collection<Int> ): UShortArray ``` Returns an array containing elements of this array at specified [indices](slice-array#kotlin.collections%24sliceArray(kotlin.Array((kotlin.collections.sliceArray.T)),%20kotlin.collections.Collection((kotlin.Int)))/indices). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<T>.sliceArray(indices: IntRange): Array<T> ``` ``` fun ByteArray.sliceArray(indices: IntRange): ByteArray ``` ``` fun ShortArray.sliceArray(indices: IntRange): ShortArray ``` ``` fun IntArray.sliceArray(indices: IntRange): IntArray ``` ``` fun LongArray.sliceArray(indices: IntRange): LongArray ``` ``` fun FloatArray.sliceArray(indices: IntRange): FloatArray ``` ``` fun DoubleArray.sliceArray(indices: IntRange): DoubleArray ``` ``` fun BooleanArray.sliceArray(indices: IntRange): BooleanArray ``` ``` fun CharArray.sliceArray(indices: IntRange): CharArray ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sliceArray(     indices: IntRange ): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sliceArray(     indices: IntRange ): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sliceArray(     indices: IntRange ): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sliceArray(     indices: IntRange ): UShortArray ``` Returns an array containing elements at indices in the specified [indices](slice-array#kotlin.collections%24sliceArray(kotlin.Array((kotlin.collections.sliceArray.T)),%20kotlin.ranges.IntRange)/indices) range. kotlin average average ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <average> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("averageOfByte") fun Array<out Byte>.average(): Double ``` ``` @JvmName("averageOfShort") fun Array<out Short>.average(): Double ``` ``` @JvmName("averageOfInt") fun Array<out Int>.average(): Double ``` ``` @JvmName("averageOfLong") fun Array<out Long>.average(): Double ``` ``` @JvmName("averageOfFloat") fun Array<out Float>.average(): Double ``` ``` @JvmName("averageOfDouble") fun Array<out Double>.average(): Double ``` ``` fun ByteArray.average(): Double ``` ``` fun ShortArray.average(): Double ``` ``` fun IntArray.average(): Double ``` ``` fun LongArray.average(): Double ``` ``` fun FloatArray.average(): Double ``` ``` fun DoubleArray.average(): Double ``` Returns an average value of elements in the array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("averageOfByte") fun Iterable<Byte>.average(): Double ``` ``` @JvmName("averageOfShort") fun Iterable<Short>.average(): Double ``` ``` @JvmName("averageOfInt") fun Iterable<Int>.average(): Double ``` ``` @JvmName("averageOfLong") fun Iterable<Long>.average(): Double ``` ``` @JvmName("averageOfFloat") fun Iterable<Float>.average(): Double ``` ``` @JvmName("averageOfDouble") fun Iterable<Double>.average(): Double ``` Returns an average value of elements in the collection. kotlin mapIndexedNotNull mapIndexedNotNull ================= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapIndexedNotNull](map-indexed-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any> Array<out T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.Array((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original array. Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. kotlin mutableMapOf mutableMapOf ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mutableMapOf](mutable-map-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <K, V> mutableMapOf(): MutableMap<K, V> ``` Returns an empty new [MutableMap](-mutable-map/index#kotlin.collections.MutableMap). The returned map preserves the entry iteration order. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mutableMapOf<Int, Any?>() println("map.isEmpty() is ${map.isEmpty()}") // true map[1] = "x" map[2] = 1.05 // Now map contains something: println(map) // {1=x, 2=1.05} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> mutableMapOf(     vararg pairs: Pair<K, V> ): MutableMap<K, V> ``` Returns a new [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) with the specified contents, given as a list of pairs where the first component is the key and the second is the value. If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs. Entries of the map are iterated in the order they were specified. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mutableMapOf(1 to "x", 2 to "y", -1 to "zz") println(map) // {1=x, 2=y, -1=zz} map[1] = "a" println(map) // {1=a, 2=y, -1=zz} //sampleEnd } ``` ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mutableMapOf<Int, Any?>() println("map.isEmpty() is ${map.isEmpty()}") // true map[1] = "x" map[2] = 1.05 // Now map contains something: println(map) // {1=x, 2=1.05} //sampleEnd } ```
programming_docs
kotlin hashSetOf hashSetOf ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [hashSetOf](hash-set-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> hashSetOf(): HashSet<T> ``` Returns an empty new [HashSet](-hash-set/index#kotlin.collections.HashSet). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> hashSetOf(vararg elements: T): HashSet<T> ``` Returns a new [HashSet](-hash-set/index#kotlin.collections.HashSet) with the given elements. kotlin isNullOrEmpty isNullOrEmpty ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [isNullOrEmpty](is-null-or-empty) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun Array<*>?.isNullOrEmpty(): Boolean ``` Returns `true` if this nullable array is either null or empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nullArray: Array<Any>? = null println("nullArray.isNullOrEmpty() is ${nullArray.isNullOrEmpty()}") // true val emptyArray: Array<Any>? = emptyArray<Any>() println("emptyArray.isNullOrEmpty() is ${emptyArray.isNullOrEmpty()}") // true val array: Array<Char>? = arrayOf('a', 'b', 'c') println("array.isNullOrEmpty() is ${array.isNullOrEmpty()}") // false //sampleEnd } ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` Returns `true` if this nullable collection is either null or empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nullList: List<Any>? = null println("nullList.isNullOrEmpty() is ${nullList.isNullOrEmpty()}") // true val empty: List<Any>? = emptyList<Any>() println("empty.isNullOrEmpty() is ${empty.isNullOrEmpty()}") // true val collection: List<Char>? = listOf('a', 'b', 'c') println("collection.isNullOrEmpty() is ${collection.isNullOrEmpty()}") // false //sampleEnd } ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean ``` Returns `true` if this nullable map is either null or empty. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val nullMap: Map<String, Any>? = null println("nullMap.isNullOrEmpty() is ${nullMap.isNullOrEmpty()}") // true val emptyMap: Map<String, Any>? = emptyMap<String, Any>() println("emptyMap.isNullOrEmpty() is ${emptyMap.isNullOrEmpty()}") // true val map: Map<Char, Int>? = mapOf('a' to 1, 'b' to 2, 'c' to 3) println("map.isNullOrEmpty() is ${map.isNullOrEmpty()}") // false //sampleEnd } ``` kotlin toMutableSet toMutableSet ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toMutableSet](to-mutable-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.toMutableSet(): MutableSet<T> ``` ``` fun ByteArray.toMutableSet(): MutableSet<Byte> ``` ``` fun ShortArray.toMutableSet(): MutableSet<Short> ``` ``` fun IntArray.toMutableSet(): MutableSet<Int> ``` ``` fun LongArray.toMutableSet(): MutableSet<Long> ``` ``` fun FloatArray.toMutableSet(): MutableSet<Float> ``` ``` fun DoubleArray.toMutableSet(): MutableSet<Double> ``` ``` fun BooleanArray.toMutableSet(): MutableSet<Boolean> ``` ``` fun CharArray.toMutableSet(): MutableSet<Char> ``` Returns a new [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given array. The returned set preserves the element iteration order of the original array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` Returns a new [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. The returned set preserves the element iteration order of the original collection. kotlin withDefault withDefault =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [withDefault](with-default) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<K, V>.withDefault(     defaultValue: (key: K) -> V ): Map<K, V> ``` Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue](with-default#kotlin.collections%24withDefault(kotlin.collections.Map((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). This implicit default value is used when the original map doesn't contain a value for the key specified and a value is obtained with [Map.getValue](get-value) function, for example when properties are delegated to the map. When this map already has an implicit default value provided with a former call to [withDefault](with-default), it is being replaced by this call. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("withDefaultMutable") fun <K, V> MutableMap<K, V>.withDefault(     defaultValue: (key: K) -> V ): MutableMap<K, V> ``` Returns a wrapper of this mutable map, having the implicit default value provided with the specified function [defaultValue](with-default#kotlin.collections%24withDefault(kotlin.collections.MutableMap((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). This implicit default value is used when the original map doesn't contain a value for the key specified and a value is obtained with [Map.getValue](get-value) function, for example when properties are delegated to the map. When this map already has an implicit default value provided with a former call to [withDefault](with-default), it is being replaced by this call. kotlin buildSet buildSet ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [buildSet](build-set) **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` inline fun <E> buildSet(     builderAction: MutableSet<E>.() -> Unit ): Set<E> ``` Builds a new read-only [Set](-set/index#kotlin.collections.Set) by populating a [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) using the given [builderAction](build-set#kotlin.collections%24buildSet(kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/builderAction) and returning a read-only set with the same elements. The set passed as a receiver to the [builderAction](build-set#kotlin.collections%24buildSet(kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/builderAction) is valid only inside that function. Using it outside of the function produces an unspecified behavior. Elements of the set are iterated in the order they were added by the [builderAction](build-set#kotlin.collections%24buildSet(kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/builderAction). The returned set is serializable (JVM). ``` fun main(args: Array<String>) { //sampleStart val x = setOf('a', 'b') val y = buildSet(x.size + 2) { add('b') addAll(x) add('c') } println(y) // [b, a, c] //sampleEnd } ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` inline fun <E> buildSet(     capacity: Int,     builderAction: MutableSet<E>.() -> Unit ): Set<E> ``` Builds a new read-only [Set](-set/index#kotlin.collections.Set) by populating a [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) using the given [builderAction](build-set#kotlin.collections%24buildSet(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/builderAction) and returning a read-only set with the same elements. The set passed as a receiver to the [builderAction](build-set#kotlin.collections%24buildSet(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/builderAction) is valid only inside that function. Using it outside of the function produces an unspecified behavior. [capacity](build-set#kotlin.collections%24buildSet(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/capacity) is used to hint the expected number of elements added in the [builderAction](build-set#kotlin.collections%24buildSet(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/builderAction). Elements of the set are iterated in the order they were added by the [builderAction](build-set#kotlin.collections%24buildSet(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/builderAction). The returned set is serializable (JVM). ``` fun main(args: Array<String>) { //sampleStart val x = setOf('a', 'b') val y = buildSet(x.size + 2) { add('b') addAll(x) add('c') } println(y) // [b, a, c] //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if the given [capacity](build-set#kotlin.collections%24buildSet(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableSet((kotlin.collections.buildSet.E)),%20kotlin.Unit)))/capacity) is negative. kotlin runningFold runningFold =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [runningFold](running-fold) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Array<out T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` ``` inline fun <R> ByteArray.runningFold(     initial: R,     operation: (acc: R, Byte) -> R ): List<R> ``` ``` inline fun <R> ShortArray.runningFold(     initial: R,     operation: (acc: R, Short) -> R ): List<R> ``` ``` inline fun <R> IntArray.runningFold(     initial: R,     operation: (acc: R, Int) -> R ): List<R> ``` ``` inline fun <R> LongArray.runningFold(     initial: R,     operation: (acc: R, Long) -> R ): List<R> ``` ``` inline fun <R> FloatArray.runningFold(     initial: R,     operation: (acc: R, Float) -> R ): List<R> ``` ``` inline fun <R> DoubleArray.runningFold(     initial: R,     operation: (acc: R, Double) -> R ): List<R> ``` ``` inline fun <R> BooleanArray.runningFold(     initial: R,     operation: (acc: R, Boolean) -> R ): List<R> ``` ``` inline fun <R> CharArray.runningFold(     initial: R,     operation: (acc: R, Char) -> R ): List<R> ``` ``` inline fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.runningFold(     initial: R,     operation: (acc: R, UInt) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.runningFold(     initial: R,     operation: (acc: R, ULong) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.runningFold(     initial: R,     operation: (acc: R, UByte) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.runningFold(     initial: R,     operation: (acc: R, UShort) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](running-fold#kotlin.collections%24runningFold(kotlin.Array((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](running-fold#kotlin.collections%24runningFold(kotlin.Array((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. Note that `acc` value passed to [operation](running-fold#kotlin.collections%24runningFold(kotlin.Array((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningFold("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.runningFoldIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().runningFold("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. kotlin dropLast dropLast ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [dropLast](drop-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.dropLast(n: Int): List<T> ``` ``` fun ByteArray.dropLast(n: Int): List<Byte> ``` ``` fun ShortArray.dropLast(n: Int): List<Short> ``` ``` fun IntArray.dropLast(n: Int): List<Int> ``` ``` fun LongArray.dropLast(n: Int): List<Long> ``` ``` fun FloatArray.dropLast(n: Int): List<Float> ``` ``` fun DoubleArray.dropLast(n: Int): List<Double> ``` ``` fun BooleanArray.dropLast(n: Int): List<Boolean> ``` ``` fun CharArray.dropLast(n: Int): List<Char> ``` ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.dropLast(     n: Int ): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.dropLast(     n: Int ): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.dropLast(     n: Int ): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.dropLast(     n: Int ): List<UShort> ``` Returns a list containing all elements except last [n](drop-last#kotlin.collections%24dropLast(kotlin.Array((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.drop(23)) // [x, y, z] println(chars.dropLast(23)) // [a, b, c] println(chars.dropWhile { it < 'x' }) // [x, y, z] println(chars.dropLastWhile { it > 'c' }) // [a, b, c] //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](drop-last#kotlin.collections%24dropLast(kotlin.Array((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) is negative. kotlin mapOf mapOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapOf](map-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> mapOf(vararg pairs: Pair<K, V>): Map<K, V> ``` Returns a new read-only map with the specified contents, given as a list of pairs where the first value is the key and the second is the value. If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs. Entries of the map are iterated in the order they were specified. The returned map is serializable (JVM). ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mapOf(1 to "x", 2 to "y", -1 to "zz") println(map) // {1=x, 2=y, -1=zz} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> mapOf(): Map<K, V> ``` Returns an empty read-only map. The returned map is serializable (JVM). ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = emptyMap<String, Int>() println("map.isEmpty() is ${map.isEmpty()}") // true val anotherMap = mapOf<String, Int>() // Empty maps are equal println("map == anotherMap is ${map == anotherMap}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0) ``` fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> ``` ##### For JVM Returns an immutable map, mapping only the specified key to the specified value. The returned map is serializable. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mapOf(1 to "x", 2 to "y", -1 to "zz") println(map) // {1=x, 2=y, -1=zz} //sampleEnd } ``` ##### For JS Returns an immutable map, mapping only the specified key to the specified value. kotlin mapIndexed mapIndexed ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapIndexed](map-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Array<out T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` ``` inline fun <R> ByteArray.mapIndexed(     transform: (index: Int, Byte) -> R ): List<R> ``` ``` inline fun <R> ShortArray.mapIndexed(     transform: (index: Int, Short) -> R ): List<R> ``` ``` inline fun <R> IntArray.mapIndexed(     transform: (index: Int, Int) -> R ): List<R> ``` ``` inline fun <R> LongArray.mapIndexed(     transform: (index: Int, Long) -> R ): List<R> ``` ``` inline fun <R> FloatArray.mapIndexed(     transform: (index: Int, Float) -> R ): List<R> ``` ``` inline fun <R> DoubleArray.mapIndexed(     transform: (index: Int, Double) -> R ): List<R> ``` ``` inline fun <R> BooleanArray.mapIndexed(     transform: (index: Int, Boolean) -> R ): List<R> ``` ``` inline fun <R> CharArray.mapIndexed(     transform: (index: Int, Char) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.mapIndexed(     transform: (index: Int, UInt) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.mapIndexed(     transform: (index: Int, ULong) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.mapIndexed(     transform: (index: Int, UByte) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.mapIndexed(     transform: (index: Int, UShort) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](map-indexed#kotlin.collections%24mapIndexed(kotlin.Array((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. kotlin sortedBy sortedBy ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedBy](sorted-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Comparable<R>> Array<out T>.sortedBy(     crossinline selector: (T) -> R? ): List<T> ``` ``` inline fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     crossinline selector: (T) -> R? ): List<T> ``` Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](sorted-by#kotlin.collections%24sortedBy(kotlin.Array((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aaa", "cc", "bbbb") val sorted = list.sortedBy { it.length } println(list) // [aaa, cc, bbbb] println(sorted) // [cc, aaa, bbbb] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R : Comparable<R>> ByteArray.sortedBy(     crossinline selector: (Byte) -> R? ): List<Byte> ``` ``` inline fun <R : Comparable<R>> ShortArray.sortedBy(     crossinline selector: (Short) -> R? ): List<Short> ``` ``` inline fun <R : Comparable<R>> IntArray.sortedBy(     crossinline selector: (Int) -> R? ): List<Int> ``` ``` inline fun <R : Comparable<R>> LongArray.sortedBy(     crossinline selector: (Long) -> R? ): List<Long> ``` ``` inline fun <R : Comparable<R>> FloatArray.sortedBy(     crossinline selector: (Float) -> R? ): List<Float> ``` ``` inline fun <R : Comparable<R>> DoubleArray.sortedBy(     crossinline selector: (Double) -> R? ): List<Double> ``` ``` inline fun <R : Comparable<R>> BooleanArray.sortedBy(     crossinline selector: (Boolean) -> R? ): List<Boolean> ``` ``` inline fun <R : Comparable<R>> CharArray.sortedBy(     crossinline selector: (Char) -> R? ): List<Char> ``` Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](sorted-by#kotlin.collections%24sortedBy(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aaa", "cc", "bbbb") val sorted = list.sortedBy { it.length } println(list) // [aaa, cc, bbbb] println(sorted) // [cc, aaa, bbbb] //sampleEnd } ```
programming_docs
kotlin toFloatArray toFloatArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toFloatArray](to-float-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Array<out Float>.toFloatArray(): FloatArray ``` Returns an array of Float containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Collection<Float>.toFloatArray(): FloatArray ``` Returns an array of Float containing all of the elements of this collection. kotlin filterIsInstance filterIsInstance ================ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterIsInstance](filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <reified R> Array<*>.filterIsInstance(): List<R> ``` ``` fun <reified R> Iterable<*>.filterIsInstance(): List<R> ``` Returns a list containing all elements that are instances of specified type parameter R. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart open class Animal(val name: String) { override fun toString(): String { return name } } class Dog(name: String): Animal(name) class Cat(name: String): Animal(name) val animals: List<Animal> = listOf(Cat("Scratchy"), Dog("Poochie")) val cats = animals.filterIsInstance<Cat>() println(cats) // [Scratchy] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0) ``` fun <R> Array<*>.filterIsInstance(klass: Class<R>): List<R> ``` ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` Returns a list containing all elements that are instances of specified class. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart open class Animal(val name: String) { override fun toString(): String { return name } } class Dog(name: String): Animal(name) class Cat(name: String): Animal(name) val animals: List<Animal> = listOf(Cat("Scratchy"), Dog("Poochie")) val cats = animals.filterIsInstance(Cat::class.java) println(cats) // [Scratchy] //sampleEnd } ``` kotlin emptySet emptySet ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [emptySet](empty-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> emptySet(): Set<T> ``` Returns an empty read-only set. The returned set is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val set = setOf<String>() println("set.isEmpty() is ${set.isEmpty()}") // true // another way to create an empty set, // type parameter is inferred from the expected type val other: Set<Int> = emptySet() // Empty sets are equal println("set == other is ${set == other}") // true println(set) // [] //sampleEnd } ``` kotlin reverse reverse ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <reverse> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<T>.reverse() ``` ``` fun ByteArray.reverse() ``` ``` fun ShortArray.reverse() ``` ``` fun IntArray.reverse() ``` ``` fun LongArray.reverse() ``` ``` fun FloatArray.reverse() ``` ``` fun DoubleArray.reverse() ``` ``` fun BooleanArray.reverse() ``` ``` fun CharArray.reverse() ``` ``` @ExperimentalUnsignedTypes fun UIntArray.reverse() ``` ``` @ExperimentalUnsignedTypes fun ULongArray.reverse() ``` ``` @ExperimentalUnsignedTypes fun UByteArray.reverse() ``` ``` @ExperimentalUnsignedTypes fun UShortArray.reverse() ``` Reverses elements in the array in-place. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<T>.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun ByteArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun ShortArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun IntArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun LongArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun FloatArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun DoubleArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun BooleanArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` fun CharArray.reverse(fromIndex: Int, toIndex: Int) ``` ``` @ExperimentalUnsignedTypes fun UIntArray.reverse(     fromIndex: Int,     toIndex: Int) ``` ``` @ExperimentalUnsignedTypes fun ULongArray.reverse(     fromIndex: Int,     toIndex: Int) ``` ``` @ExperimentalUnsignedTypes fun UByteArray.reverse(     fromIndex: Int,     toIndex: Int) ``` ``` @ExperimentalUnsignedTypes fun UShortArray.reverse(     fromIndex: Int,     toIndex: Int) ``` Reverses elements of the array in the specified range in-place. Parameters ---------- `fromIndex` - the start of the range (inclusive) to reverse. `toIndex` - the end of the range (exclusive) to reverse. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](reverse#kotlin.collections%24reverse(kotlin.Array((kotlin.collections.reverse.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](reverse#kotlin.collections%24reverse(kotlin.Array((kotlin.collections.reverse.T)),%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](reverse#kotlin.collections%24reverse(kotlin.Array((kotlin.collections.reverse.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](reverse#kotlin.collections%24reverse(kotlin.Array((kotlin.collections.reverse.T)),%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableList<T>.reverse() ``` Reverses elements in the list in-place. kotlin sortDescending sortDescending ============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortDescending](sort-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> Array<out T>.sortDescending() ``` Sorts elements in the array in-place descending according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.sortDescending() ``` ``` fun ShortArray.sortDescending() ``` ``` fun IntArray.sortDescending() ``` ``` fun LongArray.sortDescending() ``` ``` fun FloatArray.sortDescending() ``` ``` fun DoubleArray.sortDescending() ``` ``` fun CharArray.sortDescending() ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sortDescending() ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sortDescending() ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sortDescending() ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sortDescending() ``` Sorts elements in the array in-place descending according to their natural sort order. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Comparable<T>> Array<out T>.sortDescending(     fromIndex: Int,     toIndex: Int) ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. Parameters ---------- `fromIndex` - the start of the range (inclusive) to sort. `toIndex` - the end of the range (exclusive) to sort. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](sort-descending#kotlin.collections%24sortDescending(kotlin.Array((kotlin.collections.sortDescending.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](sort-descending#kotlin.collections%24sortDescending(kotlin.Array((kotlin.collections.sortDescending.T)),%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](sort-descending#kotlin.collections%24sortDescending(kotlin.Array((kotlin.collections.sortDescending.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](sort-descending#kotlin.collections%24sortDescending(kotlin.Array((kotlin.collections.sortDescending.T)),%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun ByteArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun ShortArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun IntArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun LongArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun FloatArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun DoubleArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` fun CharArray.sortDescending(fromIndex: Int, toIndex: Int) ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sortDescending(     fromIndex: Int,     toIndex: Int) ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sortDescending(     fromIndex: Int,     toIndex: Int) ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sortDescending(     fromIndex: Int,     toIndex: Int) ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sortDescending(     fromIndex: Int,     toIndex: Int) ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. Parameters ---------- `fromIndex` - the start of the range (inclusive) to sort. `toIndex` - the end of the range (exclusive) to sort. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](sort-descending#kotlin.collections%24sortDescending(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](sort-descending#kotlin.collections%24sortDescending(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](sort-descending#kotlin.collections%24sortDescending(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](sort-descending#kotlin.collections%24sortDescending(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> MutableList<T>.sortDescending() ``` Sorts elements in the list in-place descending according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. kotlin mapValues mapValues ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapValues](map-values) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R> Map<out K, V>.mapValues(     transform: (Entry<K, V>) -> R ): Map<K, R> ``` Returns a new map with entries having the keys of this map and the values obtained by applying the [transform](map-values#kotlin.collections%24mapValues(kotlin.collections.Map((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.collections.mapValues.R)))/transform) function to each entry in this [Map](-map/index#kotlin.collections.Map). The returned map preserves the entry iteration order of the original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map1 = mapOf("beverage" to 2.7, "meal" to 12.4) val map2 = map1.mapValues { it.value.toString() + "$" } println(map2) // {beverage=2.7$, meal=12.4$} //sampleEnd } ``` kotlin asIntArray asIntArray ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asIntArray](as-int-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.asIntArray(): IntArray ``` Returns an array of type [IntArray](../kotlin/-int-array/index#kotlin.IntArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. kotlin filterNotNullTo filterNotNullTo =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterNotNullTo](filter-not-null-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <C : MutableCollection<in T>, T : Any> Array<out T?>.filterNotNullTo(     destination: C ): C ``` ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` Appends all elements that are not `null` to the given [destination](filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.Array((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int?> = listOf(1, 2, null, 4) val nonNullNumbers = mutableListOf<Int>() println(nonNullNumbers) // [] numbers.filterNotNullTo(nonNullNumbers) println(nonNullNumbers) // [1, 2, 4] //sampleEnd } ``` kotlin toMap toMap ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toMap](to-map) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Returns a new map containing all key-value pairs from the given collection of pairs. The returned map preserves the entry iteration order of the original collection. If any of two pairs would have the same key the last one gets added to the map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` Populates and returns the [destination](to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V> ``` Returns a new map containing all key-value pairs from the given array of pairs. The returned map preserves the entry iteration order of the original array. If any of two pairs would have the same key the last one gets added to the map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V, M : MutableMap<in K, in V>> Array<out Pair<K, V>>.toMap(     destination: M ): M ``` Populates and returns the [destination](to-map#kotlin.collections%24toMap(kotlin.Array((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given array of pairs. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V> ``` Returns a new map containing all key-value pairs from the given sequence of pairs. The returned map preserves the entry iteration order of the original sequence. If any of two pairs would have the same key the last one gets added to the map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.toMap(     destination: M ): M ``` Populates and returns the [destination](to-map#kotlin.collections%24toMap(kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given sequence of pairs. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <K, V> Map<out K, V>.toMap(): Map<K, V> ``` Returns a new read-only map containing all key-value pairs from the original map. The returned map preserves the entry iteration order of the original map. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(     destination: M ): M ``` Populates and returns the [destination](to-map#kotlin.collections%24toMap(kotlin.collections.Map((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given map. kotlin reduceRightIndexedOrNull reduceRightIndexedOrNull ======================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reduceRightIndexedOrNull](reduce-right-indexed-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Array<out T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` ``` inline fun ByteArray.reduceRightIndexedOrNull(     operation: (index: Int, Byte, acc: Byte) -> Byte ): Byte? ``` ``` inline fun ShortArray.reduceRightIndexedOrNull(     operation: (index: Int, Short, acc: Short) -> Short ): Short? ``` ``` inline fun IntArray.reduceRightIndexedOrNull(     operation: (index: Int, Int, acc: Int) -> Int ): Int? ``` ``` inline fun LongArray.reduceRightIndexedOrNull(     operation: (index: Int, Long, acc: Long) -> Long ): Long? ``` ``` inline fun FloatArray.reduceRightIndexedOrNull(     operation: (index: Int, Float, acc: Float) -> Float ): Float? ``` ``` inline fun DoubleArray.reduceRightIndexedOrNull(     operation: (index: Int, Double, acc: Double) -> Double ): Double? ``` ``` inline fun BooleanArray.reduceRightIndexedOrNull(     operation: (index: Int, Boolean, acc: Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.reduceRightIndexedOrNull(     operation: (index: Int, Char, acc: Char) -> Char ): Char? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.reduceRightIndexedOrNull(     operation: (index: Int, UInt, acc: UInt) -> UInt ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.reduceRightIndexedOrNull(     operation: (index: Int, ULong, acc: ULong) -> ULong ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.reduceRightIndexedOrNull(     operation: (index: Int, UByte, acc: UByte) -> UByte ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.reduceRightIndexedOrNull(     operation: (index: Int, UShort, acc: UShort) -> UShort ): UShort? ``` Accumulates value starting with the last element and applying [operation](reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.Array((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. Returns `null` if the array is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRightOrNull { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexedOrNull { index, string, acc -> acc + string + index }) // dc2b1a0 println(emptyList<String>().reduceRightOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` Accumulates value starting with the last element and applying [operation](reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. Returns `null` if the list is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRightOrNull { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexedOrNull { index, string, acc -> acc + string + index }) // dc2b1a0 println(emptyList<String>().reduceRightOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value.
programming_docs
kotlin asIterable asIterable ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asIterable](as-iterable) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.asIterable(): Iterable<T> ``` ``` fun ByteArray.asIterable(): Iterable<Byte> ``` ``` fun ShortArray.asIterable(): Iterable<Short> ``` ``` fun IntArray.asIterable(): Iterable<Int> ``` ``` fun LongArray.asIterable(): Iterable<Long> ``` ``` fun FloatArray.asIterable(): Iterable<Float> ``` ``` fun DoubleArray.asIterable(): Iterable<Double> ``` ``` fun BooleanArray.asIterable(): Iterable<Boolean> ``` ``` fun CharArray.asIterable(): Iterable<Char> ``` Creates an [Iterable](-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` Returns this collection as an [Iterable](-iterable/index#kotlin.collections.Iterable). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>> ``` Creates an [Iterable](-iterable/index#kotlin.collections.Iterable) instance that wraps the original map returning its entries when being iterated. kotlin sortedArrayWith sortedArrayWith =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedArrayWith](sorted-array-with) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.sortedArrayWith(     comparator: Comparator<in T> ): Array<out T> ``` Returns an array with all elements of this array sorted according the specified [comparator](sorted-array-with#kotlin.collections%24sortedArrayWith(kotlin.Array((kotlin.collections.sortedArrayWith.T)),%20kotlin.Comparator((kotlin.collections.sortedArrayWith.T)))/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. kotlin lastIndexOf lastIndexOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [lastIndexOf](last-index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.lastIndexOf(element: T): Int ``` ``` fun ByteArray.lastIndexOf(element: Byte): Int ``` ``` fun ShortArray.lastIndexOf(element: Short): Int ``` ``` fun IntArray.lastIndexOf(element: Int): Int ``` ``` fun LongArray.lastIndexOf(element: Long): Int ``` ``` @DeprecatedSinceKotlin("1.4", "1.6", "1.7") fun FloatArray.lastIndexOf(     element: Float ): Int ``` **Deprecated:** The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfLast { it == element }' instead to continue using this behavior, or '.asList().lastIndexOf(element: T)' to get the same search behavior as in a list. ``` @DeprecatedSinceKotlin("1.4", "1.6", "1.7") fun DoubleArray.lastIndexOf(     element: Double ): Int ``` **Deprecated:** The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfLast { it == element }' instead to continue using this behavior, or '.asList().lastIndexOf(element: T)' to get the same search behavior as in a list. ``` fun BooleanArray.lastIndexOf(element: Boolean): Int ``` ``` fun CharArray.lastIndexOf(element: Char): Int ``` ``` @ExperimentalUnsignedTypes fun UIntArray.lastIndexOf(     element: UInt ): Int ``` ``` @ExperimentalUnsignedTypes fun ULongArray.lastIndexOf(     element: ULong ): Int ``` ``` @ExperimentalUnsignedTypes fun UByteArray.lastIndexOf(     element: UByte ): Int ``` ``` @ExperimentalUnsignedTypes fun UShortArray.lastIndexOf(     element: UShort ): Int ``` Returns last index of [element](last-index-of#kotlin.collections%24lastIndexOf(kotlin.Array((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the array does not contain element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. kotlin reversedArray reversedArray ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reversedArray](reversed-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<T>.reversedArray(): Array<T> ``` ``` fun ByteArray.reversedArray(): ByteArray ``` ``` fun ShortArray.reversedArray(): ShortArray ``` ``` fun IntArray.reversedArray(): IntArray ``` ``` fun LongArray.reversedArray(): LongArray ``` ``` fun FloatArray.reversedArray(): FloatArray ``` ``` fun DoubleArray.reversedArray(): DoubleArray ``` ``` fun BooleanArray.reversedArray(): BooleanArray ``` ``` fun CharArray.reversedArray(): CharArray ``` ``` @ExperimentalUnsignedTypes fun UIntArray.reversedArray(): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.reversedArray(): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.reversedArray(): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.reversedArray(): UShortArray ``` Returns an array with elements of this array in reversed order. kotlin sortedMapOf sortedMapOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedMapOf](sorted-map-of) **Platform and version requirements:** JVM (1.0) ``` fun <K : Comparable<K>, V> sortedMapOf(     vararg pairs: Pair<K, V> ): SortedMap<K, V> ``` Returns a new [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) with the specified contents, given as a list of pairs where the first value is the key and the second is the value. The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to their natural sorting order. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = sortedMapOf(Pair("c", 3), Pair("b", 2), Pair("d", 1)) println(map.keys) // [b, c, d] println(map.values) // [2, 3, 1] //sampleEnd } ``` **Platform and version requirements:** JVM (1.4) ``` fun <K, V> sortedMapOf(     comparator: Comparator<in K>,     vararg pairs: Pair<K, V> ): SortedMap<K, V> ``` Returns a new [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) with the specified contents, given as a list of pairs where the first value is the key and the second is the value. The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to the sorting order provided by the given [comparator](sorted-map-of#kotlin.collections%24sortedMapOf(java.util.Comparator((kotlin.collections.sortedMapOf.K)),%20kotlin.Array((kotlin.Pair((kotlin.collections.sortedMapOf.K,%20kotlin.collections.sortedMapOf.V)))))/comparator). ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = sortedMapOf(compareBy<String> { it.length }.thenBy { it }, Pair("abc", 1), Pair("c", 3), Pair("bd", 4), Pair("bc", 2)) println(map.keys) // [c, bc, bd, abc] println(map.values) // [3, 2, 4, 1] //sampleEnd } ``` kotlin flatten flatten ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <flatten> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out Array<out T>>.flatten(): List<T> ``` Returns a single list of all elements from all arrays in the given array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val deepArray = arrayOf( arrayOf(1), arrayOf(2, 3), arrayOf(4, 5, 6) ) println(deepArray.flatten()) // [1, 2, 3, 4, 5, 6] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` Returns a single list of all elements from all collections in the given collection. ``` fun main(args: Array<String>) { //sampleStart val deepList = listOf(listOf(1), listOf(2, 3), listOf(4, 5, 6)) println(deepList.flatten()) // [1, 2, 3, 4, 5, 6] //sampleEnd } ``` kotlin remove remove ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <remove> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> MutableMap<out K, V>.remove(key: K): V? ``` Removes the specified key and its corresponding value from this map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. Allows to overcome type-safety restriction of `remove` that requires to pass a key of type `K`. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` Removes a single instance of the specified element from this collection, if it is present. Allows to overcome type-safety restriction of `remove` that requires to pass an element of type `E`. **Return** `true` if the element has been successfully removed; `false` if it was not present in the collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableList<T>.remove(index: Int): T ``` **Deprecated:** Use removeAt(index) instead. Removes the element at the specified [index](remove#kotlin.collections%24remove(kotlin.collections.MutableList((kotlin.collections.remove.T)),%20kotlin.Int)/index) from this list. In Kotlin one should use the [MutableList.removeAt](-mutable-list/remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)) function instead. **Platform and version requirements:** JVM (1.2), JRE8 (1.2) ``` fun <K, V> MutableMap<out K, out V>.remove(     key: K,     value: V ): Boolean ``` Removes the entry for the specified key only if it is currently mapped to the specified value. kotlin binarySearch binarySearch ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [binarySearch](binary-search) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> List<T?>.binarySearch(     element: T?,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for the provided [element](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T?)),%20kotlin.collections.binarySearch.T?,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of its elements, otherwise the result is undefined. If the list contains multiple elements equal to the specified [element](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T?)),%20kotlin.collections.binarySearch.T?,%20kotlin.Int,%20kotlin.Int)/element), there is no guarantee which one will be found. `null` value is considered to be less than any non-null value. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = mutableListOf('a', 'b', 'c', 'd', 'e') println(list.binarySearch('d')) // 3 list.remove('d') val invertedInsertionPoint = list.binarySearch('d') val actualInsertionPoint = -(invertedInsertionPoint + 1) println(actualInsertionPoint) // 3 list.add(actualInsertionPoint, 'd') println(list) // [a, b, c, d, e] //sampleEnd } ``` ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'b', 'c', 'd', 'e') println(list.binarySearch('d')) // 3 // element is out of range from the left println("list.binarySearch('b', fromIndex = 2) < 0 is ${list.binarySearch('b', fromIndex = 2) < 0}") // true // element is out of range from the right println("list.binarySearch('d', toIndex = 2) < 0 is ${list.binarySearch('d', toIndex = 2) < 0}") // true //sampleEnd } ``` **Return** the index of the element, if it is contained in the list within the specified range; otherwise, the inverted insertion point `(-insertion point - 1)`. The insertion point is defined as the index at which the element should be inserted, so that the list (or the specified subrange of list) still remains sorted. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for the provided [element](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. If the list contains multiple elements equal to the specified [element](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element), there is no guarantee which one will be found. `null` value is considered to be less than any non-null value. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val colors = listOf("Blue", "green", "ORANGE", "Red", "yellow") println(colors.binarySearch("RED", String.CASE_INSENSITIVE_ORDER)) // 3 //sampleEnd } ``` **Return** the index of the element, if it is contained in the list within the specified range; otherwise, the inverted insertion point `(-insertion point - 1)`. The insertion point is defined as the index at which the element should be inserted, so that the list (or the specified subrange of list) still remains sorted according to the specified [comparator](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` Searches this list or its range for an element for which the given [comparison](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. The list is expected to be sorted so that the signs of the [comparison](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function's return values ascend on the list elements, i.e. negative values come before zero and zeroes come before positive values. Otherwise, the result is undefined. If the list contains multiple elements for which [comparison](binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) returns zero, there is no guarantee which one will be found. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Box(val value: String) val values = listOf("A", "ant", "binding", "Box", "cell") val boxes = values.map { Box(it) } val valueToFind = "box" // `boxes` list is sorted according to the following comparison function val index = boxes.binarySearch { String.CASE_INSENSITIVE_ORDER.compare(it.value, valueToFind) } if (index >= 0) { println("Value at $index is ${boxes[index]}") // Value at 3 is Box(value=Box) } else { println("Box with value=$valueToFind was not found") } //sampleEnd } ``` Parameters ---------- `comparison` - function that returns zero when called on the list element being searched. On the elements coming before the target element, the function must return negative values; on the elements coming after the target element, the function must return positive values. **Return** the index of the found element, if it is contained in the list within the specified range; otherwise, the inverted insertion point `(-insertion point - 1)`. The insertion point is defined as the index at which the element should be inserted, so that the list (or the specified subrange of list) still remains sorted. **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches the array or the range of the array for the provided [element](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted according to the specified [comparator](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. If the array contains multiple elements equal to the specified [element](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element), there is no guarantee which one will be found. Parameters ---------- `element` - the element to search for. `comparator` - the comparator according to which this array is sorted. `fromIndex` - the start of the range (inclusive) to search in, 0 by default. `toIndex` - the end of the range (exclusive) to search in, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/toIndex). **Return** the index of the element, if it is contained in the array within the specified range; otherwise, the inverted insertion point `(-insertion point - 1)`. The insertion point is defined as the index at which the element should be inserted, so that the array (or the specified subrange of array) still remains sorted according to the specified [comparator](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20java.util.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator). **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out T>.binarySearch(     element: T,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun ByteArray.binarySearch(     element: Byte,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun ShortArray.binarySearch(     element: Short,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun IntArray.binarySearch(     element: Int,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun LongArray.binarySearch(     element: Long,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun FloatArray.binarySearch(     element: Float,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun DoubleArray.binarySearch(     element: Double,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` fun CharArray.binarySearch(     element: Char,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` @ExperimentalUnsignedTypes fun UIntArray.binarySearch(     element: UInt,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` @ExperimentalUnsignedTypes fun ULongArray.binarySearch(     element: ULong,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` @ExperimentalUnsignedTypes fun UByteArray.binarySearch(     element: UByte,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` ``` @ExperimentalUnsignedTypes fun UShortArray.binarySearch(     element: UShort,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches the array or the range of the array for the provided [element](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. If the array contains multiple elements equal to the specified [element](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Int,%20kotlin.Int)/element), there is no guarantee which one will be found. Parameters ---------- `element` - the to search for. `fromIndex` - the start of the range (inclusive) to search in, 0 by default. `toIndex` - the end of the range (exclusive) to search in, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](binary-search#kotlin.collections%24binarySearch(kotlin.Array((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Int,%20kotlin.Int)/toIndex). **Return** the index of the element, if it is contained in the array within the specified range; otherwise, the inverted insertion point `(-insertion point - 1)`. The insertion point is defined as the index at which the element should be inserted, so that the array (or the specified subrange of array) still remains sorted.
programming_docs
kotlin component1 component1 ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <component1> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Array<out T>.component1(): T ``` ``` operator fun ByteArray.component1(): Byte ``` ``` operator fun ShortArray.component1(): Short ``` ``` operator fun IntArray.component1(): Int ``` ``` operator fun LongArray.component1(): Long ``` ``` operator fun FloatArray.component1(): Float ``` ``` operator fun DoubleArray.component1(): Double ``` ``` operator fun BooleanArray.component1(): Boolean ``` ``` operator fun CharArray.component1(): Char ``` ``` @ExperimentalUnsignedTypes operator fun UIntArray.component1(): UInt ``` ``` @ExperimentalUnsignedTypes operator fun ULongArray.component1(): ULong ``` ``` @ExperimentalUnsignedTypes operator fun UByteArray.component1(): UByte ``` ``` @ExperimentalUnsignedTypes operator fun UShortArray.component1(): UShort ``` Returns 1st *element* from the array. If the size of this array is less than 1, throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) except in Kotlin/JS where the behavior is unspecified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> List<T>.component1(): T ``` Returns 1st *element* from the list. Throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the size of this list is less than 1. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Entry<K, V>.component1(): K ``` Returns the key component of the map entry. This method allows to use destructuring declarations when working with maps, for example: ``` for ((key, value) in map) { // do something with the key and the value } ``` kotlin foldRightIndexed foldRightIndexed ================ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [foldRightIndexed](fold-right-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Array<out T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` ``` inline fun <R> ByteArray.foldRightIndexed(     initial: R,     operation: (index: Int, Byte, acc: R) -> R ): R ``` ``` inline fun <R> ShortArray.foldRightIndexed(     initial: R,     operation: (index: Int, Short, acc: R) -> R ): R ``` ``` inline fun <R> IntArray.foldRightIndexed(     initial: R,     operation: (index: Int, Int, acc: R) -> R ): R ``` ``` inline fun <R> LongArray.foldRightIndexed(     initial: R,     operation: (index: Int, Long, acc: R) -> R ): R ``` ``` inline fun <R> FloatArray.foldRightIndexed(     initial: R,     operation: (index: Int, Float, acc: R) -> R ): R ``` ``` inline fun <R> DoubleArray.foldRightIndexed(     initial: R,     operation: (index: Int, Double, acc: R) -> R ): R ``` ``` inline fun <R> BooleanArray.foldRightIndexed(     initial: R,     operation: (index: Int, Boolean, acc: R) -> R ): R ``` ``` inline fun <R> CharArray.foldRightIndexed(     initial: R,     operation: (index: Int, Char, acc: R) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.foldRightIndexed(     initial: R,     operation: (index: Int, UInt, acc: R) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.foldRightIndexed(     initial: R,     operation: (index: Int, ULong, acc: R) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.foldRightIndexed(     initial: R,     operation: (index: Int, UByte, acc: R) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.foldRightIndexed(     initial: R,     operation: (index: Int, UShort, acc: R) -> R ): R ``` Accumulates value starting with [initial](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.Array((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.Array((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. Returns the specified [initial](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.Array((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value if the array is empty. Parameters ---------- `operation` - function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` Accumulates value starting with [initial](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. Returns the specified [initial](fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value if the list is empty. Parameters ---------- `operation` - function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value. kotlin indices indices ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <indices> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val <T> Array<out T>.indices: IntRange ``` ``` val ByteArray.indices: IntRange ``` ``` val ShortArray.indices: IntRange ``` ``` val IntArray.indices: IntRange ``` ``` val LongArray.indices: IntRange ``` ``` val FloatArray.indices: IntRange ``` ``` val DoubleArray.indices: IntRange ``` ``` val BooleanArray.indices: IntRange ``` ``` val CharArray.indices: IntRange ``` ``` @ExperimentalUnsignedTypes inline val UIntArray.indices: IntRange ``` ``` @ExperimentalUnsignedTypes inline val ULongArray.indices: IntRange ``` ``` @ExperimentalUnsignedTypes inline val UByteArray.indices: IntRange ``` ``` @ExperimentalUnsignedTypes inline val UShortArray.indices: IntRange ``` Returns the range of valid indices for the array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val Collection<*>.indices: IntRange ``` Returns an [IntRange](../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val empty = emptyList<Any>() println("empty.indices.isEmpty() is ${empty.indices.isEmpty()}") // true val collection = listOf('a', 'b', 'c') println(collection.indices) // 0..2 //sampleEnd } ``` kotlin count count ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <count> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.count(): Int ``` ``` fun ByteArray.count(): Int ``` ``` fun ShortArray.count(): Int ``` ``` fun IntArray.count(): Int ``` ``` fun LongArray.count(): Int ``` ``` fun FloatArray.count(): Int ``` ``` fun DoubleArray.count(): Int ``` ``` fun BooleanArray.count(): Int ``` ``` fun CharArray.count(): Int ``` Returns the number of elements in this array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.count(     predicate: (T) -> Boolean ): Int ``` ``` inline fun ByteArray.count(predicate: (Byte) -> Boolean): Int ``` ``` inline fun ShortArray.count(     predicate: (Short) -> Boolean ): Int ``` ``` inline fun IntArray.count(predicate: (Int) -> Boolean): Int ``` ``` inline fun LongArray.count(predicate: (Long) -> Boolean): Int ``` ``` inline fun FloatArray.count(     predicate: (Float) -> Boolean ): Int ``` ``` inline fun DoubleArray.count(     predicate: (Double) -> Boolean ): Int ``` ``` inline fun BooleanArray.count(     predicate: (Boolean) -> Boolean ): Int ``` ``` inline fun CharArray.count(predicate: (Char) -> Boolean): Int ``` ``` inline fun <T> Iterable<T>.count(     predicate: (T) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.count(     predicate: (UInt) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.count(     predicate: (ULong) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.count(     predicate: (UByte) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.count(     predicate: (UShort) -> Boolean ): Int ``` Returns the number of elements matching the given [predicate](count#kotlin.collections%24count(kotlin.Array((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.count(): Int ``` ``` fun <T> Collection<T>.count(): Int ``` Returns the number of elements in this collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<out K, V>.count(): Int ``` Returns the number of entries in this map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.count(     predicate: (Entry<K, V>) -> Boolean ): Int ``` Returns the number of entries matching the given [predicate](count#kotlin.collections%24count(kotlin.collections.Map((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Boolean)))/predicate). kotlin flatMapIndexed flatMapIndexed ============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [flatMapIndexed](flat-map-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("flatMapIndexedIterable") inline fun <T, R> Array<out T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedIterable") inline fun <R> ByteArray.flatMapIndexed(     transform: (index: Int, Byte) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedIterable") inline fun <R> ShortArray.flatMapIndexed(     transform: (index: Int, Short) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedIterable") inline fun <R> IntArray.flatMapIndexed(     transform: (index: Int, Int) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedIterable") inline fun <R> LongArray.flatMapIndexed(     transform: (index: Int, Long) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedIterable") inline fun <R> FloatArray.flatMapIndexed(     transform: (index: Int, Float) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedIterable") inline fun <R> DoubleArray.flatMapIndexed(     transform: (index: Int, Double) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedIterable") inline fun <R> BooleanArray.flatMapIndexed(     transform: (index: Int, Boolean) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedIterable") inline fun <R> CharArray.flatMapIndexed(     transform: (index: Int, Char) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedSequence") inline fun <T, R> Array<out T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.flatMapIndexed(     transform: (index: Int, UInt) -> Iterable<R> ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.flatMapIndexed(     transform: (index: Int, ULong) -> Iterable<R> ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.flatMapIndexed(     transform: (index: Int, UByte) -> Iterable<R> ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.flatMapIndexed(     transform: (index: Int, UShort) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.Array((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val data: List<String> = listOf("Abcd", "efgh", "Klmn") val selected: List<Boolean> = data.map { it.any { c -> c.isUpperCase() } } val result = data.flatMapIndexed { index, s -> if (selected[index]) s.toList() else emptyList() } println(result) // [A, b, c, d, K, l, m, n] //sampleEnd } ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("flatMapIndexedIterable") inline fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapIndexedSequence") inline fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val data: List<String> = listOf("Abcd", "efgh", "Klmn") val selected: List<Boolean> = data.map { it.any { c -> c.isUpperCase() } } val result = data.flatMapIndexed { index, s -> if (selected[index]) s.toList() else emptyList() } println(result) // [A, b, c, d, K, l, m, n] //sampleEnd } ``` kotlin windowed windowed ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <windowed> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of snapshots of the window of the given [size](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. Several last lists may have fewer elements than the given [size](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size). Both [size](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) and [step](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step) must be positive and can be greater than the number of elements in this collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = generateSequence(1) { it + 1 } val windows = sequence.windowed(size = 5, step = 1) println(windows.take(4).toList()) // [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]] val moreSparseWindows = sequence.windowed(size = 5, step = 3) println(moreSparseWindows.take(4).toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14]] val fullWindows = sequence.take(10).windowed(size = 5, step = 3) println(fullWindows.toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8]] val partialWindows = sequence.take(10).windowed(size = 5, step = 3, partialWindows = true) println(partialWindows.toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10], [10]] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each window `step` - the number of elements to move the window forward by on an each step, by default 1 `partialWindows` - controls whether or not to keep partial windows in the end if any, by default `false` which means partial windows won't be preserved **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` Returns a list of results of applying the given [transform](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). Note that the list passed to the [transform](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function is ephemeral and is valid only inside that function. You should not store it or allow it to escape in some way, unless you made a snapshot of it. Several last lists may have fewer elements than the given [size](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size). Both [size](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) and [step](windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step) must be positive and can be greater than the number of elements in this collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val dataPoints = sequenceOf(10, 15, 18, 25, 19, 21, 14, 8, 5) val averaged = dataPoints.windowed(size = 4, step = 1, partialWindows = true) { window -> window.average() } println(averaged.toList()) // [17.0, 19.25, 20.75, 19.75, 15.5, 12.0, 9.0, 6.5, 5.0] val averagedNoPartialWindows = dataPoints.windowed(size = 4, step = 1).map { it.average() } println(averagedNoPartialWindows.toList()) // [17.0, 19.25, 20.75, 19.75, 15.5, 12.0] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each window `step` - the number of elements to move the window forward by on an each step, by default 1 `partialWindows` - controls whether or not to keep partial windows in the end if any, by default `false` which means partial windows won't be preserved
programming_docs
kotlin setOf setOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [setOf](set-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> setOf(vararg elements: T): Set<T> ``` Returns a new read-only set with the given elements. Elements of the set are iterated in the order they were specified. The returned set is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val set1 = setOf(1, 2, 3) val set2 = setOf(3, 2, 1) // setOf preserves the iteration order of elements println(set1) // [1, 2, 3] println(set2) // [3, 2, 1] // but the sets with the same elements are equal no matter of order println("set1 == set2 is ${set1 == set2}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> setOf(): Set<T> ``` Returns an empty read-only set. The returned set is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val set = setOf<String>() println("set.isEmpty() is ${set.isEmpty()}") // true // another way to create an empty set, // type parameter is inferred from the expected type val other: Set<Int> = emptySet() // Empty sets are equal println("set == other is ${set == other}") // true println(set) // [] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0) ``` fun <T> setOf(element: T): Set<T> ``` ##### For JVM Returns an immutable set containing only the specified object [element](set-of#kotlin.collections%24setOf(kotlin.collections.setOf.T)/element). The returned set is serializable. ##### For JS Returns an immutable set containing only the specified object [element](set-of#kotlin.collections%24setOf(kotlin.collections.setOf.T)/element). kotlin asList asList ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asList](as-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.asList(): List<T> ``` ``` fun ByteArray.asList(): List<Byte> ``` ``` fun ShortArray.asList(): List<Short> ``` ``` fun IntArray.asList(): List<Int> ``` ``` fun LongArray.asList(): List<Long> ``` ``` fun FloatArray.asList(): List<Float> ``` ``` fun DoubleArray.asList(): List<Double> ``` ``` fun BooleanArray.asList(): List<Boolean> ``` ``` fun CharArray.asList(): List<Char> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.asList(): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.asList(): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.asList(): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.asList(): List<UShort> ``` Returns a [List](-list/index#kotlin.collections.List) that wraps the original array. kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.asSequence(): Sequence<T> ``` ``` fun ByteArray.asSequence(): Sequence<Byte> ``` ``` fun ShortArray.asSequence(): Sequence<Short> ``` ``` fun IntArray.asSequence(): Sequence<Int> ``` ``` fun LongArray.asSequence(): Sequence<Long> ``` ``` fun FloatArray.asSequence(): Sequence<Float> ``` ``` fun DoubleArray.asSequence(): Sequence<Double> ``` ``` fun BooleanArray.asSequence(): Sequence<Boolean> ``` ``` fun CharArray.asSequence(): Sequence<Char> ``` Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original array returning its elements when being iterated. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf('a', 'b', 'c') val sequence = array.asSequence() println(sequence.joinToString()) // a, b, c //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val collection = listOf('a', 'b', 'c') val sequence = collection.asSequence() println(sequence.joinToString()) // a, b, c //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>> ``` Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original map returning its entries when being iterated. kotlin scanIndexed scanIndexed =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [scanIndexed](scan-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Array<out T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` ``` inline fun <R> ByteArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> R ): List<R> ``` ``` inline fun <R> ShortArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> R ): List<R> ``` ``` inline fun <R> IntArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> R ): List<R> ``` ``` inline fun <R> LongArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> R ): List<R> ``` ``` inline fun <R> FloatArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> R ): List<R> ``` ``` inline fun <R> DoubleArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> R ): List<R> ``` ``` inline fun <R> BooleanArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> R ): List<R> ``` ``` inline fun <R> CharArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, UShort) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](scan-indexed#kotlin.collections%24scanIndexed(kotlin.Array((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with [initial](scan-indexed#kotlin.collections%24scanIndexed(kotlin.Array((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. Note that `acc` value passed to [operation](scan-indexed#kotlin.collections%24scanIndexed(kotlin.Array((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.scan("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.scanIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().scan("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. Note that `acc` value passed to [operation](scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.scan("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.scanIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().scan("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. kotlin RandomAccess RandomAccess ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [RandomAccess](-random-access) **Platform and version requirements:** JS (1.1) ``` interface RandomAccess ``` **Platform and version requirements:** JVM (1.1) ``` typealias RandomAccess = RandomAccess ``` Marker interface indicating that the [List](-list/index#kotlin.collections.List) implementation supports fast indexed access. Inheritors ---------- #### [ArrayList](-array-list/index) Provides a [MutableList](-mutable-list/index#kotlin.collections.MutableList) implementation, which uses a resizable array as its backing storage. **Platform and version requirements:** ``` class ArrayList<E> : MutableList<E>, RandomAccess ``` **Platform and version requirements:** JVM (1.1) ``` typealias ArrayList<E> = ArrayList<E> ``` **Platform and version requirements:** JS (1.1) ``` open class ArrayList<E> :      AbstractMutableList<E>,     MutableList<E>,     RandomAccess ``` kotlin sortWith sortWith ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortWith](sort-with) **Platform and version requirements:** JS (1.0), Native (1.0) ``` fun <T> Array<out T>.sortWith(comparator: Comparator<in T>) ``` Sorts the array in-place according to the order specified by the given [comparator](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20kotlin.Comparator((kotlin.collections.sortWith.T)))/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JS (1.0), Native (1.0) ``` fun <T> Array<out T>.sortWith(     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size) ``` Sorts a range in the array in-place with the given [comparator](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20kotlin.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. Parameters ---------- `fromIndex` - the start of the range (inclusive) to sort, 0 by default. `toIndex` - the end of the range (exclusive) to sort, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20kotlin.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20kotlin.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20kotlin.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20kotlin.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JS (1.0) ``` fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>) ``` Sorts elements in the list in-place according to the order specified with [comparator](sort-with#kotlin.collections%24sortWith(kotlin.collections.MutableList((kotlin.collections.sortWith.T)),%20kotlin.Comparator((kotlin.collections.sortWith.T)))/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart // non-comparable class class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val people = mutableListOf( Person("Ragnar", "Lodbrok"), Person("Bjorn", "Ironside"), Person("Sweyn", "Forkbeard") ) people.sortWith(compareByDescending { it.firstName }) // after sorting println(people.joinToString()) // Sweyn Forkbeard, Ragnar Lodbrok, Bjorn Ironside //sampleEnd } ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out T>.sortWith(comparator: Comparator<in T>) ``` Sorts the array in-place according to the order specified by the given [comparator](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)))/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out T>.sortWith(     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size) ``` Sorts a range in the array in-place with the given [comparator](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. Parameters ---------- `fromIndex` - the start of the range (inclusive) to sort, 0 by default. `toIndex` - the end of the range (exclusive) to sort, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.0) ``` fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>) ``` Sorts elements in the list in-place according to the order specified with [comparator](sort-with#kotlin.collections%24sortWith(kotlin.collections.MutableList((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)))/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart // non-comparable class class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val people = mutableListOf( Person("Ragnar", "Lodbrok"), Person("Bjorn", "Ironside"), Person("Sweyn", "Forkbeard") ) people.sortWith(compareByDescending { it.firstName }) // after sorting println(people.joinToString()) // Sweyn Forkbeard, Ragnar Lodbrok, Bjorn Ironside //sampleEnd } ``` kotlin toPair toPair ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toPair](to-pair) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Entry<K, V>.toPair(): Pair<K, V> ``` Converts entry to [Pair](../kotlin/-pair/index) with key being first component and value being second. kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [retainAll](retain-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only the elements in this collection that are contained in the specified collection. Allows to overcome type-safety restriction of `retainAll` that requires to pass a collection of type `Collection<E>`. **Return** `true` if any element was removed from the collection, `false` if the collection was not modified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` Retains only elements of this [MutableIterable](-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). **Return** `true` if any element was removed from this collection, or `false` when all elements were retained and collection was not modified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableList<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` Retains only elements of this [MutableList](-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableList((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). **Return** `true` if any element was removed from this collection, or `false` when all elements were retained and collection was not modified.
programming_docs
kotlin mutableSetOf mutableSetOf ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mutableSetOf](mutable-set-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> mutableSetOf(): MutableSet<T> ``` Returns an empty new [MutableSet](-mutable-set/index#kotlin.collections.MutableSet). The returned set preserves the element iteration order. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val set = mutableSetOf<Int>() println("set.isEmpty() is ${set.isEmpty()}") // true set.add(1) set.add(2) set.add(1) println(set) // [1, 2] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> mutableSetOf(vararg elements: T): MutableSet<T> ``` Returns a new [MutableSet](-mutable-set/index#kotlin.collections.MutableSet) with the given elements. Elements of the set are iterated in the order they were specified. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val set = mutableSetOf(1, 2, 3) println(set) // [1, 2, 3] set.remove(3) set += listOf(4, 5) println(set) // [1, 2, 4, 5] //sampleEnd } ``` kotlin firstOrNull firstOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [firstOrNull](first-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.firstOrNull(): T? ``` ``` fun ByteArray.firstOrNull(): Byte? ``` ``` fun ShortArray.firstOrNull(): Short? ``` ``` fun IntArray.firstOrNull(): Int? ``` ``` fun LongArray.firstOrNull(): Long? ``` ``` fun FloatArray.firstOrNull(): Float? ``` ``` fun DoubleArray.firstOrNull(): Double? ``` ``` fun BooleanArray.firstOrNull(): Boolean? ``` ``` fun CharArray.firstOrNull(): Char? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.firstOrNull(): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.firstOrNull(): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.firstOrNull(): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.firstOrNull(): UShort? ``` Returns the first element, or `null` if the array is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` ``` inline fun ByteArray.firstOrNull(     predicate: (Byte) -> Boolean ): Byte? ``` ``` inline fun ShortArray.firstOrNull(     predicate: (Short) -> Boolean ): Short? ``` ``` inline fun IntArray.firstOrNull(     predicate: (Int) -> Boolean ): Int? ``` ``` inline fun LongArray.firstOrNull(     predicate: (Long) -> Boolean ): Long? ``` ``` inline fun FloatArray.firstOrNull(     predicate: (Float) -> Boolean ): Float? ``` ``` inline fun DoubleArray.firstOrNull(     predicate: (Double) -> Boolean ): Double? ``` ``` inline fun BooleanArray.firstOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.firstOrNull(     predicate: (Char) -> Boolean ): Char? ``` ``` inline fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.firstOrNull(     predicate: (UInt) -> Boolean ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.firstOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.firstOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.firstOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` Returns the first element matching the given [predicate](first-or-null#kotlin.collections%24firstOrNull(kotlin.Array((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element, or `null` if the collection is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.firstOrNull(): T? ``` Returns the first element, or `null` if the list is empty. kotlin sortedArray sortedArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedArray](sorted-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> Array<T>.sortedArray(): Array<T> ``` Returns an array with all elements of this array sorted according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.sortedArray(): ByteArray ``` ``` fun ShortArray.sortedArray(): ShortArray ``` ``` fun IntArray.sortedArray(): IntArray ``` ``` fun LongArray.sortedArray(): LongArray ``` ``` fun FloatArray.sortedArray(): FloatArray ``` ``` fun DoubleArray.sortedArray(): DoubleArray ``` ``` fun CharArray.sortedArray(): CharArray ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sortedArray(): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sortedArray(): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sortedArray(): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sortedArray(): UShortArray ``` Returns an array with all elements of this array sorted according to their natural sort order. kotlin copyInto copyInto ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [copyInto](copy-into) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Array<out T>.copyInto(     destination: Array<T>,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): Array<T> ``` ``` fun ByteArray.copyInto(     destination: ByteArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): ByteArray ``` ``` fun ShortArray.copyInto(     destination: ShortArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): ShortArray ``` ``` fun IntArray.copyInto(     destination: IntArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): IntArray ``` ``` fun LongArray.copyInto(     destination: LongArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): LongArray ``` ``` fun FloatArray.copyInto(     destination: FloatArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): FloatArray ``` ``` fun DoubleArray.copyInto(     destination: DoubleArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): DoubleArray ``` ``` fun BooleanArray.copyInto(     destination: BooleanArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): BooleanArray ``` ``` fun CharArray.copyInto(     destination: CharArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): CharArray ``` Copies this array or its subrange into the [destination](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array and returns that array. It's allowed to pass the same array in the [destination](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) and even specify the subrange so that it overlaps with the destination range. Parameters ---------- `destination` - the array to copy to. `destinationOffset` - the position in the [destination](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array to copy to, 0 by default. `startIndex` - the beginning (inclusive) of the subrange to copy, 0 by default. `endIndex` - the end (exclusive) of the subrange to copy, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) when [startIndex](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/startIndex) or [endIndex](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/endIndex) is out of range of this array indices or when `startIndex > endIndex`. `IndexOutOfBoundsException` - when the subrange doesn't fit into the [destination](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array starting at the specified [destinationOffset](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destinationOffset), or when that index is out of the [destination](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array indices range. **Return** the [destination](copy-into#kotlin.collections%24copyInto(kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Array((kotlin.collections.copyInto.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.copyInto(     destination: UIntArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.copyInto(     destination: ULongArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.copyInto(     destination: UByteArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.copyInto(     destination: UShortArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): UShortArray ``` Copies this array or its subrange into the [destination](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array and returns that array. It's allowed to pass the same array in the [destination](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) and even specify the subrange so that it overlaps with the destination range. Parameters ---------- `destination` - the array to copy to. `destinationOffset` - the position in the [destination](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array to copy to, 0 by default. `startIndex` - the beginning (inclusive) of the subrange to copy, 0 by default. `endIndex` - the end (exclusive) of the subrange to copy, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) when [startIndex](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/startIndex) or [endIndex](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/endIndex) is out of range of this array indices or when `startIndex > endIndex`. `IndexOutOfBoundsException` - when the subrange doesn't fit into the [destination](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array starting at the specified [destinationOffset](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destinationOffset), or when that index is out of the [destination](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array indices range. **Return** the [destination](copy-into#kotlin.collections%24copyInto(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array. kotlin maxOf maxOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxOf](max-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Array<out T>.maxOf(     selector: (T) -> Double ): Double ``` ``` inline fun ByteArray.maxOf(     selector: (Byte) -> Double ): Double ``` ``` inline fun ShortArray.maxOf(     selector: (Short) -> Double ): Double ``` ``` inline fun IntArray.maxOf(selector: (Int) -> Double): Double ``` ``` inline fun LongArray.maxOf(     selector: (Long) -> Double ): Double ``` ``` inline fun FloatArray.maxOf(     selector: (Float) -> Double ): Double ``` ``` inline fun DoubleArray.maxOf(     selector: (Double) -> Double ): Double ``` ``` inline fun BooleanArray.maxOf(     selector: (Boolean) -> Double ): Double ``` ``` inline fun CharArray.maxOf(     selector: (Char) -> Double ): Double ``` ``` inline fun <T> Array<out T>.maxOf(     selector: (T) -> Float ): Float ``` ``` inline fun ByteArray.maxOf(selector: (Byte) -> Float): Float ``` ``` inline fun ShortArray.maxOf(     selector: (Short) -> Float ): Float ``` ``` inline fun IntArray.maxOf(selector: (Int) -> Float): Float ``` ``` inline fun LongArray.maxOf(selector: (Long) -> Float): Float ``` ``` inline fun FloatArray.maxOf(     selector: (Float) -> Float ): Float ``` ``` inline fun DoubleArray.maxOf(     selector: (Double) -> Float ): Float ``` ``` inline fun BooleanArray.maxOf(     selector: (Boolean) -> Float ): Float ``` ``` inline fun CharArray.maxOf(selector: (Char) -> Float): Float ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.maxOf(     selector: (UInt) -> Double ): Double ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.maxOf(     selector: (ULong) -> Double ): Double ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.maxOf(     selector: (UByte) -> Double ): Double ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.maxOf(     selector: (UShort) -> Double ): Double ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.maxOf(     selector: (UInt) -> Float ): Float ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.maxOf(     selector: (ULong) -> Float ): Float ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.maxOf(     selector: (UByte) -> Float ): Float ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.maxOf(     selector: (UShort) -> Float ): Float ``` Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.Array((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. If any of values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.Array((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Array<out T>.maxOf(     selector: (T) -> R ): R ``` ``` inline fun <R : Comparable<R>> ByteArray.maxOf(     selector: (Byte) -> R ): R ``` ``` inline fun <R : Comparable<R>> ShortArray.maxOf(     selector: (Short) -> R ): R ``` ``` inline fun <R : Comparable<R>> IntArray.maxOf(     selector: (Int) -> R ): R ``` ``` inline fun <R : Comparable<R>> LongArray.maxOf(     selector: (Long) -> R ): R ``` ``` inline fun <R : Comparable<R>> FloatArray.maxOf(     selector: (Float) -> R ): R ``` ``` inline fun <R : Comparable<R>> DoubleArray.maxOf(     selector: (Double) -> R ): R ``` ``` inline fun <R : Comparable<R>> BooleanArray.maxOf(     selector: (Boolean) -> R ): R ``` ``` inline fun <R : Comparable<R>> CharArray.maxOf(     selector: (Char) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.maxOf(     selector: (UInt) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.maxOf(     selector: (ULong) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.maxOf(     selector: (UByte) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.maxOf(     selector: (UShort) -> R ): R ``` Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.Array((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.collections.maxOf.R)))/selector) function applied to each element in the array. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Iterable<T>.maxOf(     selector: (T) -> Double ): Double ``` ``` inline fun <T> Iterable<T>.maxOf(     selector: (T) -> Float ): Float ``` Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. If any of values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.collections.maxOf.R)))/selector) function applied to each element in the collection. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` inline fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Float ): Float ``` Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. If any of values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. Exceptions ---------- `NoSuchElementException` - if the map is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> R ): R ``` Returns the largest value among all values produced by [selector](max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.collections.maxOf.R)))/selector) function applied to each entry in the map. Exceptions ---------- `NoSuchElementException` - if the map is empty.
programming_docs
kotlin toUIntArray toUIntArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toUIntArray](to-u-int-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun Array<out UInt>.toUIntArray(): UIntArray ``` Returns an array of UInt containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun IntArray.toUIntArray(): UIntArray ``` Returns an array of type [UIntArray](../kotlin/-u-int-array/index), which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun Collection<UInt>.toUIntArray(): UIntArray ``` Returns an array of UInt containing all of the elements of this collection. kotlin getValue getValue ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [getValue](get-value) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <V, V1 : V> Map<in String, V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V1 ``` Returns the value of the property for the given object from this read-only map. Parameters ---------- `thisRef` - the object for which the value is requested (not used). `property` - the metadata for the property, used to get the name of property and lookup the value corresponding to this name in the map. Exceptions ---------- `NoSuchElementException` - when the map doesn't contain value for the property name and doesn't provide an implicit default (see [withDefault](with-default)). **Return** the property value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("getVar") operator fun <V, V1 : V> MutableMap<in String, out V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V1 ``` Returns the value of the property for the given object from this mutable map. Parameters ---------- `thisRef` - the object for which the value is requested (not used). `property` - the metadata for the property, used to get the name of property and lookup the value corresponding to this name in the map. Exceptions ---------- `NoSuchElementException` - when the map doesn't contain value for the property name and doesn't provide an implicit default (see [withDefault](with-default)). **Return** the property value. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <K, V> Map<K, V>.getValue(key: K): V ``` Returns the value for the given [key](get-value#kotlin.collections%24getValue(kotlin.collections.Map((kotlin.collections.getValue.K,%20kotlin.collections.getValue.V)),%20kotlin.collections.getValue.K)/key) or throws an exception if there is no such key in the map. If the map was created by [withDefault](with-default), resorts to its `defaultValue` provider function instead of throwing an exception. Exceptions ---------- `NoSuchElementException` - when the map doesn't contain a value for the specified key and no implicit default value was provided for that map. kotlin toBooleanArray toBooleanArray ============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toBooleanArray](to-boolean-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Array<out Boolean>.toBooleanArray(): BooleanArray ``` Returns an array of Boolean containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` Returns an array of Boolean containing all of the elements of this collection. kotlin hashMapOf hashMapOf ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [hashMapOf](hash-map-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <K, V> hashMapOf(): HashMap<K, V> ``` Returns an empty new [HashMap](-hash-map/index#kotlin.collections.HashMap). ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = hashMapOf<Int, Any?>() println("map.isEmpty() is ${map.isEmpty()}") // true map[1] = "x" map[2] = 1.05 // Now map contains something: println(map) // {1=x, 2=1.05} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): HashMap<K, V> ``` Returns a new [HashMap](-hash-map/index#kotlin.collections.HashMap) with the specified contents, given as a list of pairs where the first component is the key and the second is the value. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map: HashMap<Int, String> = hashMapOf(1 to "x", 2 to "y", -1 to "zz") println(map) // {-1=zz, 1=x, 2=y} //sampleEnd } ``` kotlin singleOrNull singleOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [singleOrNull](single-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.singleOrNull(): T? ``` ``` fun ByteArray.singleOrNull(): Byte? ``` ``` fun ShortArray.singleOrNull(): Short? ``` ``` fun IntArray.singleOrNull(): Int? ``` ``` fun LongArray.singleOrNull(): Long? ``` ``` fun FloatArray.singleOrNull(): Float? ``` ``` fun DoubleArray.singleOrNull(): Double? ``` ``` fun BooleanArray.singleOrNull(): Boolean? ``` ``` fun CharArray.singleOrNull(): Char? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.singleOrNull(): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.singleOrNull(): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.singleOrNull(): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.singleOrNull(): UShort? ``` Returns single element, or `null` if the array is empty or has more than one element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` ``` inline fun ByteArray.singleOrNull(     predicate: (Byte) -> Boolean ): Byte? ``` ``` inline fun ShortArray.singleOrNull(     predicate: (Short) -> Boolean ): Short? ``` ``` inline fun IntArray.singleOrNull(     predicate: (Int) -> Boolean ): Int? ``` ``` inline fun LongArray.singleOrNull(     predicate: (Long) -> Boolean ): Long? ``` ``` inline fun FloatArray.singleOrNull(     predicate: (Float) -> Boolean ): Float? ``` ``` inline fun DoubleArray.singleOrNull(     predicate: (Double) -> Boolean ): Double? ``` ``` inline fun BooleanArray.singleOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.singleOrNull(     predicate: (Char) -> Boolean ): Char? ``` ``` inline fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.singleOrNull(     predicate: (UInt) -> Boolean ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.singleOrNull(     predicate: (ULong) -> Boolean ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.singleOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.singleOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` Returns the single element matching the given [predicate](single-or-null#kotlin.collections%24singleOrNull(kotlin.Array((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns single element, or `null` if the collection is empty or has more than one element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.singleOrNull(): T? ``` Returns single element, or `null` if the list is empty or has more than one element. kotlin sortBy sortBy ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortBy](sort-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Comparable<R>> Array<out T>.sortBy(     crossinline selector: (T) -> R?) ``` Sorts elements in the array in-place according to natural sort order of the value returned by specified [selector](sort-by#kotlin.collections%24sortBy(kotlin.Array((kotlin.collections.sortBy.T)),%20kotlin.Function1((kotlin.collections.sortBy.T,%20kotlin.collections.sortBy.R?)))/selector) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Comparable<R>> MutableList<T>.sortBy(     crossinline selector: (T) -> R?) ``` Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector](sort-by#kotlin.collections%24sortBy(kotlin.collections.MutableList((kotlin.collections.sortBy.T)),%20kotlin.Function1((kotlin.collections.sortBy.T,%20kotlin.collections.sortBy.R?)))/selector) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. kotlin aggregate aggregate ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <aggregate> **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K, R> Grouping<T, K>.aggregate(     operation: (key: K, accumulator: R?, element: T, first: Boolean) -> R ): Map<K, R> ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](aggregate#kotlin.collections%24aggregate(kotlin.collections.Grouping((kotlin.collections.aggregate.T,%20kotlin.collections.aggregate.K)),%20kotlin.Function4((kotlin.collections.aggregate.K,%20kotlin.collections.aggregate.R?,%20kotlin.collections.aggregate.T,%20kotlin.Boolean,%20kotlin.collections.aggregate.R)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. The key for each element is provided by the [Grouping.keyOf](-grouping/key-of) function. ``` fun main(args: Array<String>) { //sampleStart val numbers = listOf(3, 4, 5, 6, 7, 8, 9) val aggregated = numbers.groupingBy { it % 3 }.aggregate { key, accumulator: StringBuilder?, element, first -> if (first) // first element StringBuilder().append(key).append(":").append(element) else accumulator!!.append("-").append(element) } println(aggregated.values) // [0:3-6-9, 1:4-7, 2:5-8] //sampleEnd } ``` Parameters ---------- `operation` - function is invoked on each element with the following parameters: **Return** a [Map](-map/index#kotlin.collections.Map) associating the key of each group with the result of aggregation of the group elements. kotlin listOfNotNull listOfNotNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [listOfNotNull](list-of-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> listOfNotNull(element: T?): List<T> ``` Returns a new read-only list either of single given element, if it is not null, or empty list if the element is null. The returned list is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val empty = listOfNotNull<Any>(null) println(empty) // [] val singleton = listOfNotNull(42) println(singleton) // [42] val list = listOfNotNull(1, null, 2, null, 3) println(list) // [1, 2, 3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> listOfNotNull(vararg elements: T?): List<T> ``` Returns a new read-only list only of those given elements, that are not null. The returned list is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val empty = listOfNotNull<Any>(null) println(empty) // [] val singleton = listOfNotNull(42) println(singleton) // [42] val list = listOfNotNull(1, null, 2, null, 3) println(list) // [1, 2, 3] //sampleEnd } ``` kotlin sum sum === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <sum> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("sumOfByte") fun Array<out Byte>.sum(): Int ``` ``` @JvmName("sumOfShort") fun Array<out Short>.sum(): Int ``` ``` @JvmName("sumOfInt") fun Array<out Int>.sum(): Int ``` ``` @JvmName("sumOfLong") fun Array<out Long>.sum(): Long ``` ``` @JvmName("sumOfFloat") fun Array<out Float>.sum(): Float ``` ``` @JvmName("sumOfDouble") fun Array<out Double>.sum(): Double ``` ``` fun ByteArray.sum(): Int ``` ``` fun ShortArray.sum(): Int ``` ``` fun IntArray.sum(): Int ``` ``` fun LongArray.sum(): Long ``` ``` fun FloatArray.sum(): Float ``` ``` fun DoubleArray.sum(): Double ``` ``` @JvmName("sumOfUInt") fun Array<out UInt>.sum(): UInt ``` ``` @JvmName("sumOfULong") fun Array<out ULong>.sum(): ULong ``` ``` @JvmName("sumOfUByte") fun Array<out UByte>.sum(): UInt ``` ``` @JvmName("sumOfUShort") fun Array<out UShort>.sum(): UInt ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sum(): UInt ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sum(): ULong ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sum(): UInt ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sum(): UInt ``` Returns the sum of all elements in the array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("sumOfByte") fun Iterable<Byte>.sum(): Int ``` ``` @JvmName("sumOfShort") fun Iterable<Short>.sum(): Int ``` ``` @JvmName("sumOfInt") fun Iterable<Int>.sum(): Int ``` ``` @JvmName("sumOfLong") fun Iterable<Long>.sum(): Long ``` ``` @JvmName("sumOfFloat") fun Iterable<Float>.sum(): Float ``` ``` @JvmName("sumOfDouble") fun Iterable<Double>.sum(): Double ``` ``` @JvmName("sumOfUInt") fun Iterable<UInt>.sum(): UInt ``` ``` @JvmName("sumOfULong") fun Iterable<ULong>.sum(): ULong ``` ``` @JvmName("sumOfUByte") fun Iterable<UByte>.sum(): UInt ``` ``` @JvmName("sumOfUShort") fun Iterable<UShort>.sum(): UInt ``` Returns the sum of all elements in the collection. kotlin zip zip === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <zip> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T, R> Array<out T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` ``` infix fun <R> ByteArray.zip(     other: Array<out R> ): List<Pair<Byte, R>> ``` ``` infix fun <R> ShortArray.zip(     other: Array<out R> ): List<Pair<Short, R>> ``` ``` infix fun <R> IntArray.zip(     other: Array<out R> ): List<Pair<Int, R>> ``` ``` infix fun <R> LongArray.zip(     other: Array<out R> ): List<Pair<Long, R>> ``` ``` infix fun <R> FloatArray.zip(     other: Array<out R> ): List<Pair<Float, R>> ``` ``` infix fun <R> DoubleArray.zip(     other: Array<out R> ): List<Pair<Double, R>> ``` ``` infix fun <R> BooleanArray.zip(     other: Array<out R> ): List<Pair<Boolean, R>> ``` ``` infix fun <R> CharArray.zip(     other: Array<out R> ): List<Pair<Char, R>> ``` ``` infix fun ByteArray.zip(     other: ByteArray ): List<Pair<Byte, Byte>> ``` ``` infix fun ShortArray.zip(     other: ShortArray ): List<Pair<Short, Short>> ``` ``` infix fun IntArray.zip(other: IntArray): List<Pair<Int, Int>> ``` ``` infix fun LongArray.zip(     other: LongArray ): List<Pair<Long, Long>> ``` ``` infix fun FloatArray.zip(     other: FloatArray ): List<Pair<Float, Float>> ``` ``` infix fun DoubleArray.zip(     other: DoubleArray ): List<Pair<Double, Double>> ``` ``` infix fun BooleanArray.zip(     other: BooleanArray ): List<Pair<Boolean, Boolean>> ``` ``` infix fun CharArray.zip(     other: CharArray ): List<Pair<Char, Char>> ``` ``` @ExperimentalUnsignedTypes infix fun <R> UIntArray.zip(     other: Array<out R> ): List<Pair<UInt, R>> ``` ``` @ExperimentalUnsignedTypes infix fun <R> ULongArray.zip(     other: Array<out R> ): List<Pair<ULong, R>> ``` ``` @ExperimentalUnsignedTypes infix fun <R> UByteArray.zip(     other: Array<out R> ): List<Pair<UByte, R>> ``` ``` @ExperimentalUnsignedTypes infix fun <R> UShortArray.zip(     other: Array<out R> ): List<Pair<UShort, R>> ``` ``` @ExperimentalUnsignedTypes infix fun UIntArray.zip(     other: UIntArray ): List<Pair<UInt, UInt>> ``` ``` @ExperimentalUnsignedTypes infix fun ULongArray.zip(     other: ULongArray ): List<Pair<ULong, ULong>> ``` ``` @ExperimentalUnsignedTypes infix fun UByteArray.zip(     other: UByteArray ): List<Pair<UByte, UByte>> ``` ``` @ExperimentalUnsignedTypes infix fun UShortArray.zip(     other: UShortArray ): List<Pair<UShort, UShort>> ``` Returns a list of pairs built from the elements of `this` array and the [other](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) println(listA zip listB) // [(a, 1), (b, 2), (c, 3)] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, V> Array<out T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` ``` inline fun <R, V> ByteArray.zip(     other: Array<out R>,     transform: (a: Byte, b: R) -> V ): List<V> ``` ``` inline fun <R, V> ShortArray.zip(     other: Array<out R>,     transform: (a: Short, b: R) -> V ): List<V> ``` ``` inline fun <R, V> IntArray.zip(     other: Array<out R>,     transform: (a: Int, b: R) -> V ): List<V> ``` ``` inline fun <R, V> LongArray.zip(     other: Array<out R>,     transform: (a: Long, b: R) -> V ): List<V> ``` ``` inline fun <R, V> FloatArray.zip(     other: Array<out R>,     transform: (a: Float, b: R) -> V ): List<V> ``` ``` inline fun <R, V> DoubleArray.zip(     other: Array<out R>,     transform: (a: Double, b: R) -> V ): List<V> ``` ``` inline fun <R, V> BooleanArray.zip(     other: Array<out R>,     transform: (a: Boolean, b: R) -> V ): List<V> ``` ``` inline fun <R, V> CharArray.zip(     other: Array<out R>,     transform: (a: Char, b: R) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <R, V> UIntArray.zip(     other: Array<out R>,     transform: (a: UInt, b: R) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <R, V> ULongArray.zip(     other: Array<out R>,     transform: (a: ULong, b: R) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <R, V> UByteArray.zip(     other: Array<out R>,     transform: (a: UByte, b: R) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <R, V> UShortArray.zip(     other: Array<out R>,     transform: (a: UShort, b: R) -> V ): List<V> ``` Returns a list of values built from the elements of `this` array and the [other](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) val result = listA.zip(listB) { a, b -> "$a$b" } println(result) // [a1, b2, c3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T, R> Array<out T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` ``` infix fun <R> ByteArray.zip(     other: Iterable<R> ): List<Pair<Byte, R>> ``` ``` infix fun <R> ShortArray.zip(     other: Iterable<R> ): List<Pair<Short, R>> ``` ``` infix fun <R> IntArray.zip(     other: Iterable<R> ): List<Pair<Int, R>> ``` ``` infix fun <R> LongArray.zip(     other: Iterable<R> ): List<Pair<Long, R>> ``` ``` infix fun <R> FloatArray.zip(     other: Iterable<R> ): List<Pair<Float, R>> ``` ``` infix fun <R> DoubleArray.zip(     other: Iterable<R> ): List<Pair<Double, R>> ``` ``` infix fun <R> BooleanArray.zip(     other: Iterable<R> ): List<Pair<Boolean, R>> ``` ``` infix fun <R> CharArray.zip(     other: Iterable<R> ): List<Pair<Char, R>> ``` ``` @ExperimentalUnsignedTypes infix fun <R> UIntArray.zip(     other: Iterable<R> ): List<Pair<UInt, R>> ``` ``` @ExperimentalUnsignedTypes infix fun <R> ULongArray.zip(     other: Iterable<R> ): List<Pair<ULong, R>> ``` ``` @ExperimentalUnsignedTypes infix fun <R> UByteArray.zip(     other: Iterable<R> ): List<Pair<UByte, R>> ``` ``` @ExperimentalUnsignedTypes infix fun <R> UShortArray.zip(     other: Iterable<R> ): List<Pair<UShort, R>> ``` Returns a list of pairs built from the elements of `this` collection and [other](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) println(listA zip listB) // [(a, 1), (b, 2), (c, 3)] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, V> Array<out T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` ``` inline fun <R, V> ByteArray.zip(     other: Iterable<R>,     transform: (a: Byte, b: R) -> V ): List<V> ``` ``` inline fun <R, V> ShortArray.zip(     other: Iterable<R>,     transform: (a: Short, b: R) -> V ): List<V> ``` ``` inline fun <R, V> IntArray.zip(     other: Iterable<R>,     transform: (a: Int, b: R) -> V ): List<V> ``` ``` inline fun <R, V> LongArray.zip(     other: Iterable<R>,     transform: (a: Long, b: R) -> V ): List<V> ``` ``` inline fun <R, V> FloatArray.zip(     other: Iterable<R>,     transform: (a: Float, b: R) -> V ): List<V> ``` ``` inline fun <R, V> DoubleArray.zip(     other: Iterable<R>,     transform: (a: Double, b: R) -> V ): List<V> ``` ``` inline fun <R, V> BooleanArray.zip(     other: Iterable<R>,     transform: (a: Boolean, b: R) -> V ): List<V> ``` ``` inline fun <R, V> CharArray.zip(     other: Iterable<R>,     transform: (a: Char, b: R) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <R, V> UIntArray.zip(     other: Iterable<R>,     transform: (a: UInt, b: R) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <R, V> ULongArray.zip(     other: Iterable<R>,     transform: (a: ULong, b: R) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <R, V> UByteArray.zip(     other: Iterable<R>,     transform: (a: UByte, b: R) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <R, V> UShortArray.zip(     other: Iterable<R>,     transform: (a: UShort, b: R) -> V ): List<V> ``` Returns a list of values built from the elements of `this` array and the [other](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.Array((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) val result = listA.zip(listB) { a, b -> "$a$b" } println(result) // [a1, b2, c3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <V> ByteArray.zip(     other: ByteArray,     transform: (a: Byte, b: Byte) -> V ): List<V> ``` ``` inline fun <V> ShortArray.zip(     other: ShortArray,     transform: (a: Short, b: Short) -> V ): List<V> ``` ``` inline fun <V> IntArray.zip(     other: IntArray,     transform: (a: Int, b: Int) -> V ): List<V> ``` ``` inline fun <V> LongArray.zip(     other: LongArray,     transform: (a: Long, b: Long) -> V ): List<V> ``` ``` inline fun <V> FloatArray.zip(     other: FloatArray,     transform: (a: Float, b: Float) -> V ): List<V> ``` ``` inline fun <V> DoubleArray.zip(     other: DoubleArray,     transform: (a: Double, b: Double) -> V ): List<V> ``` ``` inline fun <V> BooleanArray.zip(     other: BooleanArray,     transform: (a: Boolean, b: Boolean) -> V ): List<V> ``` ``` inline fun <V> CharArray.zip(     other: CharArray,     transform: (a: Char, b: Char) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <V> UIntArray.zip(     other: UIntArray,     transform: (a: UInt, b: UInt) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <V> ULongArray.zip(     other: ULongArray,     transform: (a: ULong, b: ULong) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <V> UByteArray.zip(     other: UByteArray,     transform: (a: UByte, b: UByte) -> V ): List<V> ``` ``` @ExperimentalUnsignedTypes inline fun <V> UShortArray.zip(     other: UShortArray,     transform: (a: UShort, b: UShort) -> V ): List<V> ``` Returns a list of values built from the elements of `this` array and the [other](zip#kotlin.collections%24zip(kotlin.ByteArray,%20kotlin.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.ByteArray,%20kotlin.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) val result = listA.zip(listB) { a, b -> "$a$b" } println(result) // [a1, b2, c3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of pairs built from the elements of `this` collection and the [other](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) println(listA zip listB) // [(a, 1), (b, 2), (c, 3)] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of values built from the elements of `this` collection and the [other](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) val result = listA.zip(listB) { a, b -> "$a$b" } println(result) // [a1, b2, c3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of pairs built from the elements of `this` collection and [other](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) println(listA zip listB) // [(a, 1), (b, 2), (c, 3)] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of values built from the elements of `this` collection and the [other](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun main(args: Array<String>) { //sampleStart val listA = listOf("a", "b", "c") val listB = listOf(1, 2, 3, 4) val result = listA.zip(listB) { a, b -> "$a$b" } println(result) // [a1, b2, c3] //sampleEnd } ```
programming_docs
kotlin randomOrNull randomOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [randomOrNull](random-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<out T>.randomOrNull(): T? ``` ``` fun ByteArray.randomOrNull(): Byte? ``` ``` fun ShortArray.randomOrNull(): Short? ``` ``` fun IntArray.randomOrNull(): Int? ``` ``` fun LongArray.randomOrNull(): Long? ``` ``` fun FloatArray.randomOrNull(): Float? ``` ``` fun DoubleArray.randomOrNull(): Double? ``` ``` fun BooleanArray.randomOrNull(): Boolean? ``` ``` fun CharArray.randomOrNull(): Char? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.randomOrNull(): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.randomOrNull(): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.randomOrNull(): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.randomOrNull(): UShort? ``` Returns a random element from this array, or `null` if this array is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<out T>.randomOrNull(random: Random): T? ``` ``` fun ByteArray.randomOrNull(random: Random): Byte? ``` ``` fun ShortArray.randomOrNull(random: Random): Short? ``` ``` fun IntArray.randomOrNull(random: Random): Int? ``` ``` fun LongArray.randomOrNull(random: Random): Long? ``` ``` fun FloatArray.randomOrNull(random: Random): Float? ``` ``` fun DoubleArray.randomOrNull(random: Random): Double? ``` ``` fun BooleanArray.randomOrNull(random: Random): Boolean? ``` ``` fun CharArray.randomOrNull(random: Random): Char? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.randomOrNull(     random: Random ): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.randomOrNull(     random: Random ): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.randomOrNull(     random: Random ): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.randomOrNull(     random: Random ): UShort? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection, or `null` if this collection is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. kotlin sortedSetOf sortedSetOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedSetOf](sorted-set-of) **Platform and version requirements:** JVM (1.0) ``` fun <T> sortedSetOf(vararg elements: T): TreeSet<T> ``` Returns a new [java.util.SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) with the given elements. **Platform and version requirements:** JVM (1.0) ``` fun <T> sortedSetOf(     comparator: Comparator<in T>,     vararg elements: T ): TreeSet<T> ``` Returns a new [java.util.SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) with the given [comparator](sorted-set-of#kotlin.collections%24sortedSetOf(java.util.Comparator((kotlin.collections.sortedSetOf.T)),%20kotlin.Array((kotlin.collections.sortedSetOf.T)))/comparator) and elements. kotlin takeLast takeLast ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [takeLast](take-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.takeLast(n: Int): List<T> ``` ``` fun ByteArray.takeLast(n: Int): List<Byte> ``` ``` fun ShortArray.takeLast(n: Int): List<Short> ``` ``` fun IntArray.takeLast(n: Int): List<Int> ``` ``` fun LongArray.takeLast(n: Int): List<Long> ``` ``` fun FloatArray.takeLast(n: Int): List<Float> ``` ``` fun DoubleArray.takeLast(n: Int): List<Double> ``` ``` fun BooleanArray.takeLast(n: Int): List<Boolean> ``` ``` fun CharArray.takeLast(n: Int): List<Char> ``` ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.takeLast(     n: Int ): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.takeLast(     n: Int ): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.takeLast(     n: Int ): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.takeLast(     n: Int ): List<UShort> ``` Returns a list containing last [n](take-last#kotlin.collections%24takeLast(kotlin.Array((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.take(3)) // [a, b, c] println(chars.takeWhile { it < 'f' }) // [a, b, c, d, e] println(chars.takeLast(2)) // [y, z] println(chars.takeLastWhile { it > 'w' }) // [x, y, z] //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](take-last#kotlin.collections%24takeLast(kotlin.Array((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) is negative. kotlin reduceRight reduceRight =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reduceRight](reduce-right) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> Array<out T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` ``` inline fun ByteArray.reduceRight(     operation: (Byte, acc: Byte) -> Byte ): Byte ``` ``` inline fun ShortArray.reduceRight(     operation: (Short, acc: Short) -> Short ): Short ``` ``` inline fun IntArray.reduceRight(     operation: (Int, acc: Int) -> Int ): Int ``` ``` inline fun LongArray.reduceRight(     operation: (Long, acc: Long) -> Long ): Long ``` ``` inline fun FloatArray.reduceRight(     operation: (Float, acc: Float) -> Float ): Float ``` ``` inline fun DoubleArray.reduceRight(     operation: (Double, acc: Double) -> Double ): Double ``` ``` inline fun BooleanArray.reduceRight(     operation: (Boolean, acc: Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.reduceRight(     operation: (Char, acc: Char) -> Char ): Char ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.reduceRight(     operation: (UInt, acc: UInt) -> UInt ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.reduceRight(     operation: (ULong, acc: ULong) -> ULong ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.reduceRight(     operation: (UByte, acc: UByte) -> UByte ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.reduceRight(     operation: (UShort, acc: UShort) -> UShort ): UShort ``` Accumulates value starting with the last element and applying [operation](reduce-right#kotlin.collections%24reduceRight(kotlin.Array((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. Throws an exception if this array is empty. If the array can be empty in an expected way, please use [reduceRightOrNull](reduce-right-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRight { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexed { index, string, acc -> acc + string + index }) // dc2b1a0 // emptyList<Int>().reduceRight { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes an element and current accumulator value, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` Accumulates value starting with the last element and applying [operation](reduce-right#kotlin.collections%24reduceRight(kotlin.collections.List((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. Throws an exception if this list is empty. If the list can be empty in an expected way, please use [reduceRightOrNull](reduce-right-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRight { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexed { index, string, acc -> acc + string + index }) // dc2b1a0 // emptyList<Int>().reduceRight { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes an element and current accumulator value, and calculates the next accumulator value. kotlin groupBy groupBy ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [groupBy](group-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> Array<out T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` ``` inline fun <K> ByteArray.groupBy(     keySelector: (Byte) -> K ): Map<K, List<Byte>> ``` ``` inline fun <K> ShortArray.groupBy(     keySelector: (Short) -> K ): Map<K, List<Short>> ``` ``` inline fun <K> IntArray.groupBy(     keySelector: (Int) -> K ): Map<K, List<Int>> ``` ``` inline fun <K> LongArray.groupBy(     keySelector: (Long) -> K ): Map<K, List<Long>> ``` ``` inline fun <K> FloatArray.groupBy(     keySelector: (Float) -> K ): Map<K, List<Float>> ``` ``` inline fun <K> DoubleArray.groupBy(     keySelector: (Double) -> K ): Map<K, List<Double>> ``` ``` inline fun <K> BooleanArray.groupBy(     keySelector: (Boolean) -> K ): Map<K, List<Boolean>> ``` ``` inline fun <K> CharArray.groupBy(     keySelector: (Char) -> K ): Map<K, List<Char>> ``` ``` @ExperimentalUnsignedTypes inline fun <K> UIntArray.groupBy(     keySelector: (UInt) -> K ): Map<K, List<UInt>> ``` ``` @ExperimentalUnsignedTypes inline fun <K> ULongArray.groupBy(     keySelector: (ULong) -> K ): Map<K, List<ULong>> ``` ``` @ExperimentalUnsignedTypes inline fun <K> UByteArray.groupBy(     keySelector: (UByte) -> K ): Map<K, List<UByte>> ``` ``` @ExperimentalUnsignedTypes inline fun <K> UShortArray.groupBy(     keySelector: (UShort) -> K ): Map<K, List<UShort>> ``` Groups elements of the original array by the key returned by the given [keySelector](group-by#kotlin.collections%24groupBy(kotlin.Array((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. The returned map preserves the entry iteration order of the keys produced from the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val byLength = words.groupBy { it.length } println(byLength.keys) // [1, 3, 2, 4] println(byLength.values) // [[a], [abc, def], [ab], [abcd]] val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } // same content as in byLength map, but the map is mutable println("mutableByLength == byLength is ${mutableByLength == byLength}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Array<out T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` ``` inline fun <K, V> ByteArray.groupBy(     keySelector: (Byte) -> K,     valueTransform: (Byte) -> V ): Map<K, List<V>> ``` ``` inline fun <K, V> ShortArray.groupBy(     keySelector: (Short) -> K,     valueTransform: (Short) -> V ): Map<K, List<V>> ``` ``` inline fun <K, V> IntArray.groupBy(     keySelector: (Int) -> K,     valueTransform: (Int) -> V ): Map<K, List<V>> ``` ``` inline fun <K, V> LongArray.groupBy(     keySelector: (Long) -> K,     valueTransform: (Long) -> V ): Map<K, List<V>> ``` ``` inline fun <K, V> FloatArray.groupBy(     keySelector: (Float) -> K,     valueTransform: (Float) -> V ): Map<K, List<V>> ``` ``` inline fun <K, V> DoubleArray.groupBy(     keySelector: (Double) -> K,     valueTransform: (Double) -> V ): Map<K, List<V>> ``` ``` inline fun <K, V> BooleanArray.groupBy(     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> V ): Map<K, List<V>> ``` ``` inline fun <K, V> CharArray.groupBy(     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): Map<K, List<V>> ``` ``` @ExperimentalUnsignedTypes inline fun <K, V> UIntArray.groupBy(     keySelector: (UInt) -> K,     valueTransform: (UInt) -> V ): Map<K, List<V>> ``` ``` @ExperimentalUnsignedTypes inline fun <K, V> ULongArray.groupBy(     keySelector: (ULong) -> K,     valueTransform: (ULong) -> V ): Map<K, List<V>> ``` ``` @ExperimentalUnsignedTypes inline fun <K, V> UByteArray.groupBy(     keySelector: (UByte) -> K,     valueTransform: (UByte) -> V ): Map<K, List<V>> ``` ``` @ExperimentalUnsignedTypes inline fun <K, V> UShortArray.groupBy(     keySelector: (UShort) -> K,     valueTransform: (UShort) -> V ): Map<K, List<V>> ``` Groups values returned by the [valueTransform](group-by#kotlin.collections%24groupBy(kotlin.Array((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original array by the key returned by the given [keySelector](group-by#kotlin.collections%24groupBy(kotlin.Array((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. The returned map preserves the entry iteration order of the keys produced from the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing") val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first }) println(namesByTeam) // {Marketing=[Alice, Carol], Sales=[Bob]} val mutableNamesByTeam = nameToTeam.groupByTo(HashMap(), { it.second }, { it.first }) // same content as in namesByTeam map, but the map is mutable println("mutableNamesByTeam == namesByTeam is ${mutableNamesByTeam == namesByTeam}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups elements of the original collection by the key returned by the given [keySelector](group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. The returned map preserves the entry iteration order of the keys produced from the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val byLength = words.groupBy { it.length } println(byLength.keys) // [1, 3, 2, 4] println(byLength.values) // [[a], [abc, def], [ab], [abcd]] val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } // same content as in byLength map, but the map is mutable println("mutableByLength == byLength is ${mutableByLength == byLength}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` Groups values returned by the [valueTransform](group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. The returned map preserves the entry iteration order of the keys produced from the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing") val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first }) println(namesByTeam) // {Marketing=[Alice, Carol], Sales=[Bob]} val mutableNamesByTeam = nameToTeam.groupByTo(HashMap(), { it.second }, { it.first }) // same content as in namesByTeam map, but the map is mutable println("mutableNamesByTeam == namesByTeam is ${mutableNamesByTeam == namesByTeam}") // true //sampleEnd } ``` kotlin containsKey containsKey =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [containsKey](contains-key) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K> Map<out K, *>.containsKey(key: K): Boolean ``` Returns `true` if the map contains the specified [key](contains-key#kotlin.collections%24containsKey(kotlin.collections.Map((kotlin.collections.containsKey.K,%20kotlin.Any?)),%20kotlin.collections.containsKey.K)/key). Allows to overcome type-safety restriction of `containsKey` that requires to pass a key of type `K`. kotlin takeWhile takeWhile ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [takeWhile](take-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` inline fun ByteArray.takeWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` inline fun ShortArray.takeWhile(     predicate: (Short) -> Boolean ): List<Short> ``` ``` inline fun IntArray.takeWhile(     predicate: (Int) -> Boolean ): List<Int> ``` ``` inline fun LongArray.takeWhile(     predicate: (Long) -> Boolean ): List<Long> ``` ``` inline fun FloatArray.takeWhile(     predicate: (Float) -> Boolean ): List<Float> ``` ``` inline fun DoubleArray.takeWhile(     predicate: (Double) -> Boolean ): List<Double> ``` ``` inline fun BooleanArray.takeWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.takeWhile(     predicate: (Char) -> Boolean ): List<Char> ``` ``` inline fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.takeWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.takeWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.takeWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.takeWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` Returns a list containing first elements satisfying the given [predicate](take-while#kotlin.collections%24takeWhile(kotlin.Array((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.take(3)) // [a, b, c] println(chars.takeWhile { it < 'f' }) // [a, b, c, d, e] println(chars.takeLast(2)) // [y, z] println(chars.takeLastWhile { it > 'w' }) // [x, y, z] //sampleEnd } ```
programming_docs
kotlin sumOf sumOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sumOf](sum-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun <T> Array<out T>.sumOf(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun ByteArray.sumOf(     selector: (Byte) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun ShortArray.sumOf(     selector: (Short) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun IntArray.sumOf(     selector: (Int) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun LongArray.sumOf(     selector: (Long) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun FloatArray.sumOf(     selector: (Float) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun DoubleArray.sumOf(     selector: (Double) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun BooleanArray.sumOf(     selector: (Boolean) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun CharArray.sumOf(     selector: (Char) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun <T> Array<out T>.sumOf(     selector: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun ByteArray.sumOf(     selector: (Byte) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun ShortArray.sumOf(     selector: (Short) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun IntArray.sumOf(     selector: (Int) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun LongArray.sumOf(     selector: (Long) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun FloatArray.sumOf(     selector: (Float) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun DoubleArray.sumOf(     selector: (Double) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun BooleanArray.sumOf(     selector: (Boolean) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun CharArray.sumOf(     selector: (Char) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun <T> Array<out T>.sumOf(     selector: (T) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun ByteArray.sumOf(     selector: (Byte) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun ShortArray.sumOf(     selector: (Short) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun IntArray.sumOf(     selector: (Int) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun LongArray.sumOf(     selector: (Long) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun FloatArray.sumOf(     selector: (Float) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun DoubleArray.sumOf(     selector: (Double) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun BooleanArray.sumOf(     selector: (Boolean) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun CharArray.sumOf(     selector: (Char) -> Long ): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun <T> Array<out T>.sumOf(     selector: (T) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun ByteArray.sumOf(     selector: (Byte) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun ShortArray.sumOf(     selector: (Short) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun IntArray.sumOf(     selector: (Int) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun LongArray.sumOf(     selector: (Long) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun FloatArray.sumOf(     selector: (Float) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun DoubleArray.sumOf(     selector: (Double) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun BooleanArray.sumOf(     selector: (Boolean) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun CharArray.sumOf(     selector: (Char) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun <T> Array<out T>.sumOf(     selector: (T) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun ByteArray.sumOf(     selector: (Byte) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun ShortArray.sumOf(     selector: (Short) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun IntArray.sumOf(     selector: (Int) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun LongArray.sumOf(     selector: (Long) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun FloatArray.sumOf(     selector: (Float) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun DoubleArray.sumOf(     selector: (Double) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun BooleanArray.sumOf(     selector: (Boolean) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun CharArray.sumOf(     selector: (Char) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") @ExperimentalUnsignedTypes inline fun UIntArray.sumOf(     selector: (UInt) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") @ExperimentalUnsignedTypes inline fun ULongArray.sumOf(     selector: (ULong) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") @ExperimentalUnsignedTypes inline fun UByteArray.sumOf(     selector: (UByte) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") @ExperimentalUnsignedTypes inline fun UShortArray.sumOf(     selector: (UShort) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") @ExperimentalUnsignedTypes inline fun UIntArray.sumOf(     selector: (UInt) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") @ExperimentalUnsignedTypes inline fun ULongArray.sumOf(     selector: (ULong) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") @ExperimentalUnsignedTypes inline fun UByteArray.sumOf(     selector: (UByte) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") @ExperimentalUnsignedTypes inline fun UShortArray.sumOf(     selector: (UShort) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") @ExperimentalUnsignedTypes inline fun UIntArray.sumOf(     selector: (UInt) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") @ExperimentalUnsignedTypes inline fun ULongArray.sumOf(     selector: (ULong) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") @ExperimentalUnsignedTypes inline fun UByteArray.sumOf(     selector: (UByte) -> Long ): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") @ExperimentalUnsignedTypes inline fun UShortArray.sumOf(     selector: (UShort) -> Long ): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") @ExperimentalUnsignedTypes inline fun UIntArray.sumOf(     selector: (UInt) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") @ExperimentalUnsignedTypes inline fun ULongArray.sumOf(     selector: (ULong) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") @ExperimentalUnsignedTypes inline fun UByteArray.sumOf(     selector: (UByte) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") @ExperimentalUnsignedTypes inline fun UShortArray.sumOf(     selector: (UShort) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") @ExperimentalUnsignedTypes inline fun UIntArray.sumOf(     selector: (UInt) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") @ExperimentalUnsignedTypes inline fun ULongArray.sumOf(     selector: (ULong) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") @ExperimentalUnsignedTypes inline fun UByteArray.sumOf(     selector: (UByte) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") @ExperimentalUnsignedTypes inline fun UShortArray.sumOf(     selector: (UShort) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun <T> Array<out T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun ByteArray.sumOf(     selector: (Byte) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun ShortArray.sumOf(     selector: (Short) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun IntArray.sumOf(     selector: (Int) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun LongArray.sumOf(     selector: (Long) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun FloatArray.sumOf(     selector: (Float) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun DoubleArray.sumOf(     selector: (Double) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun BooleanArray.sumOf(     selector: (Boolean) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun CharArray.sumOf(     selector: (Char) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun <T> Array<out T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun ByteArray.sumOf(     selector: (Byte) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun ShortArray.sumOf(     selector: (Short) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun IntArray.sumOf(     selector: (Int) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun LongArray.sumOf(     selector: (Long) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun FloatArray.sumOf(     selector: (Float) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun DoubleArray.sumOf(     selector: (Double) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun BooleanArray.sumOf(     selector: (Boolean) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun CharArray.sumOf(     selector: (Char) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") @ExperimentalUnsignedTypes inline fun UIntArray.sumOf(     selector: (UInt) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") @ExperimentalUnsignedTypes inline fun ULongArray.sumOf(     selector: (ULong) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") @ExperimentalUnsignedTypes inline fun UByteArray.sumOf(     selector: (UByte) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") @ExperimentalUnsignedTypes inline fun UShortArray.sumOf(     selector: (UShort) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") @ExperimentalUnsignedTypes inline fun UIntArray.sumOf(     selector: (UInt) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") @ExperimentalUnsignedTypes inline fun ULongArray.sumOf(     selector: (ULong) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") @ExperimentalUnsignedTypes inline fun UByteArray.sumOf(     selector: (UByte) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") @ExperimentalUnsignedTypes inline fun UShortArray.sumOf(     selector: (UShort) -> BigInteger ): BigInteger ``` Returns the sum of all values produced by [selector](sum-of#kotlin.collections%24sumOf(kotlin.Array((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun <T> Iterable<T>.sumOf(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun <T> Iterable<T>.sumOf(     selector: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun <T> Iterable<T>.sumOf(     selector: (T) -> Long ): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun <T> Iterable<T>.sumOf(     selector: (T) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun <T> Iterable<T>.sumOf(     selector: (T) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` Returns the sum of all values produced by [selector](sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. kotlin toHashSet toHashSet ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toHashSet](to-hash-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.toHashSet(): HashSet<T> ``` ``` fun ByteArray.toHashSet(): HashSet<Byte> ``` ``` fun ShortArray.toHashSet(): HashSet<Short> ``` ``` fun IntArray.toHashSet(): HashSet<Int> ``` ``` fun LongArray.toHashSet(): HashSet<Long> ``` ``` fun FloatArray.toHashSet(): HashSet<Float> ``` ``` fun DoubleArray.toHashSet(): HashSet<Double> ``` ``` fun BooleanArray.toHashSet(): HashSet<Boolean> ``` ``` fun CharArray.toHashSet(): HashSet<Char> ``` ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` Returns a new [HashSet](-hash-set/index#kotlin.collections.HashSet) of all elements. kotlin asByteArray asByteArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asByteArray](as-byte-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UByteArray.asByteArray(): ByteArray ``` Returns an array of type [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. kotlin reduceTo reduceTo ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reduceTo](reduce-to) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <S, T : S, K, M : MutableMap<in K, S>> Grouping<T, K>.reduceTo(     destination: M,     operation: (key: K, accumulator: S, element: T) -> S ): M ``` Groups elements from the [Grouping](-grouping/index) source by key and applies the reducing [operation](reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/operation) to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/destination) map. An initial value of accumulator is the first element of the group. If the [destination](reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/destination) map already has a value corresponding to the key of some group, that value is used as an initial value of the accumulator for that group and the first element of that group is also subjected to the [operation](reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/operation). ``` fun main(args: Array<String>) { //sampleStart val animals = listOf("raccoon", "reindeer", "cow", "camel", "giraffe", "goat") val maxVowels = mutableMapOf<Char, String>() // grouping by first char and collect only max of contains vowels val compareByVowelCount = compareBy { s: String -> s.count { it in "aeiou" } } animals.groupingBy { it.first() }.reduceTo(maxVowels) { _, a, b -> maxOf(a, b, compareByVowelCount) } println(maxVowels) // {r=reindeer, c=camel, g=giraffe} val moreAnimals = listOf("capybara", "rat") moreAnimals.groupingBy { it.first() }.reduceTo(maxVowels) { _, a, b -> maxOf(a, b, compareByVowelCount) } println(maxVowels) // {r=reindeer, c=capybara, g=giraffe} //sampleEnd } ``` Parameters ---------- `operation` - a function that is invoked on each subsequent element of the group with the following parameters: **Return** the [destination](reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/destination) map associating the key of each group with the result of accumulating the group elements.
programming_docs
kotlin toSortedSet toSortedSet =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toSortedSet](to-sorted-set) **Platform and version requirements:** JVM (1.0) ``` fun <T : Comparable<T>> Array<out T>.toSortedSet(): SortedSet<T> ``` ``` fun ByteArray.toSortedSet(): SortedSet<Byte> ``` ``` fun ShortArray.toSortedSet(): SortedSet<Short> ``` ``` fun IntArray.toSortedSet(): SortedSet<Int> ``` ``` fun LongArray.toSortedSet(): SortedSet<Long> ``` ``` fun FloatArray.toSortedSet(): SortedSet<Float> ``` ``` fun DoubleArray.toSortedSet(): SortedSet<Double> ``` ``` fun BooleanArray.toSortedSet(): SortedSet<Boolean> ``` ``` fun CharArray.toSortedSet(): SortedSet<Char> ``` ``` fun <T : Comparable<T>> Iterable<T>.toSortedSet(): SortedSet<T> ``` Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. Elements in the set returned are sorted according to the given [comparator](to-sorted-set#kotlin.collections%24toSortedSet(kotlin.Array((kotlin.collections.toSortedSet.T)),%20java.util.Comparator((kotlin.collections.toSortedSet.T)))/comparator). kotlin maxWith maxWith ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxWith](max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("maxWithOrThrow") fun <T> Array<out T>.maxWith(     comparator: Comparator<in T> ): T ``` ``` @JvmName("maxWithOrThrow") fun ByteArray.maxWith(     comparator: Comparator<in Byte> ): Byte ``` ``` @JvmName("maxWithOrThrow") fun ShortArray.maxWith(     comparator: Comparator<in Short> ): Short ``` ``` @JvmName("maxWithOrThrow") fun IntArray.maxWith(     comparator: Comparator<in Int> ): Int ``` ``` @JvmName("maxWithOrThrow") fun LongArray.maxWith(     comparator: Comparator<in Long> ): Long ``` ``` @JvmName("maxWithOrThrow") fun FloatArray.maxWith(     comparator: Comparator<in Float> ): Float ``` ``` @JvmName("maxWithOrThrow") fun DoubleArray.maxWith(     comparator: Comparator<in Double> ): Double ``` ``` @JvmName("maxWithOrThrow") fun BooleanArray.maxWith(     comparator: Comparator<in Boolean> ): Boolean ``` ``` @JvmName("maxWithOrThrow") fun CharArray.maxWith(     comparator: Comparator<in Char> ): Char ``` ``` @JvmName("maxWithOrThrow-U") @ExperimentalUnsignedTypes fun UIntArray.maxWith(     comparator: Comparator<in UInt> ): UInt ``` ``` @JvmName("maxWithOrThrow-U") @ExperimentalUnsignedTypes fun ULongArray.maxWith(     comparator: Comparator<in ULong> ): ULong ``` ``` @JvmName("maxWithOrThrow-U") @ExperimentalUnsignedTypes fun UByteArray.maxWith(     comparator: Comparator<in UByte> ): UByte ``` ``` @JvmName("maxWithOrThrow-U") @ExperimentalUnsignedTypes fun UShortArray.maxWith(     comparator: Comparator<in UShort> ): UShort ``` Returns the first element having the largest value according to the provided [comparator](max-with#kotlin.collections%24maxWith(kotlin.Array((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("maxWithOrThrow") fun <T> Iterable<T>.maxWith(     comparator: Comparator<in T> ): T ``` Returns the first element having the largest value according to the provided [comparator](max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("maxWithOrThrow") fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` Returns the first entry having the largest value according to the provided [comparator](max-with#kotlin.collections%24maxWith(kotlin.collections.Map((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)))))/comparator). Exceptions ---------- `NoSuchElementException` - if the map is empty. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T> Array<out T>.maxWith(     comparator: Comparator<in T> ): T? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun ByteArray.maxWith(     comparator: Comparator<in Byte> ): Byte? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun ShortArray.maxWith(     comparator: Comparator<in Short> ): Short? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun IntArray.maxWith(     comparator: Comparator<in Int> ): Int? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun LongArray.maxWith(     comparator: Comparator<in Long> ): Long? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun FloatArray.maxWith(     comparator: Comparator<in Float> ): Float? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun DoubleArray.maxWith(     comparator: Comparator<in Double> ): Double? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun BooleanArray.maxWith(     comparator: Comparator<in Boolean> ): Boolean? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun CharArray.maxWith(     comparator: Comparator<in Char> ): Char? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T> Iterable<T>.maxWith(     comparator: Comparator<in T> ): T? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UIntArray.maxWith(     comparator: Comparator<in UInt> ): UInt? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun ULongArray.maxWith(     comparator: Comparator<in ULong> ): ULong? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UByteArray.maxWith(     comparator: Comparator<in UByte> ): UByte? ``` **Deprecated:** Use maxWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UShortArray.maxWith(     comparator: Comparator<in UShort> ): UShort? ``` **Deprecated:** Use maxWithOrNull instead. kotlin filterTo filterTo ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterTo](filter-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, C : MutableCollection<in T>> Array<out T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Byte>> ByteArray.filterTo(     destination: C,     predicate: (Byte) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Short>> ShortArray.filterTo(     destination: C,     predicate: (Short) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Int>> IntArray.filterTo(     destination: C,     predicate: (Int) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Long>> LongArray.filterTo(     destination: C,     predicate: (Long) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Float>> FloatArray.filterTo(     destination: C,     predicate: (Float) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Double>> DoubleArray.filterTo(     destination: C,     predicate: (Double) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterTo(     destination: C,     predicate: (Boolean) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Char>> CharArray.filterTo(     destination: C,     predicate: (Char) -> Boolean ): C ``` ``` inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UInt>> UIntArray.filterTo(     destination: C,     predicate: (UInt) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in ULong>> ULongArray.filterTo(     destination: C,     predicate: (ULong) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UByte>> UByteArray.filterTo(     destination: C,     predicate: (UByte) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UShort>> UShortArray.filterTo(     destination: C,     predicate: (UShort) -> Boolean ): C ``` Appends all elements matching the given [predicate](filter-to#kotlin.collections%24filterTo(kotlin.Array((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-to#kotlin.collections%24filterTo(kotlin.Array((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = mutableListOf<Int>() val notMultiplesOf3 = mutableListOf<Int>() println(evenNumbers) // [] numbers.filterTo(evenNumbers) { it % 2 == 0 } numbers.filterNotTo(notMultiplesOf3) { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` Appends all entries matching the given [predicate](filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/predicate) into the mutable map given as [destination](filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/destination) parameter. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val originalMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3) val destinationMap = mutableMapOf("key40" to 40, "key50" to 50) val filteredMap = originalMap.filterTo(destinationMap) { it.value < 3 } //destination map is updated with filtered items from the original map println("destinationMap === filteredMap is ${destinationMap === filteredMap}") // true println(destinationMap) // {key40=40, key50=50, key1=1, key2=2} // original map has not changed println(originalMap) // {key1=1, key2=2, key3=3} val nonMatchingPredicate: ((Map.Entry<String, Int>)) -> Boolean = { it.value == 0 } val anotherDestinationMap = mutableMapOf("key40" to 40, "key50" to 50) val filteredMapWithNothingMatched = originalMap.filterTo(anotherDestinationMap, nonMatchingPredicate) println(filteredMapWithNothingMatched) // {key40=40, key50=50} //sampleEnd } ``` **Return** the destination map. kotlin arrayListOf arrayListOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [arrayListOf](array-list-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> arrayListOf(): ArrayList<T> ``` Returns an empty new [ArrayList](-array-list/index#kotlin.collections.ArrayList). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = arrayListOf<Int>() println("list.isEmpty() is ${list.isEmpty()}") // true list.addAll(listOf(1, 2, 3)) println(list) // [1, 2, 3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> arrayListOf(vararg elements: T): ArrayList<T> ``` Returns a new [ArrayList](-array-list/index#kotlin.collections.ArrayList) with the given elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = arrayListOf(1, 2, 3) println(list) // [1, 2, 3] list += listOf(4, 5) println(list) // [1, 2, 3, 4, 5] //sampleEnd } ``` kotlin flatMap flatMap ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [flatMap](flat-map) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Array<out T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` inline fun <R> ByteArray.flatMap(     transform: (Byte) -> Iterable<R> ): List<R> ``` ``` inline fun <R> ShortArray.flatMap(     transform: (Short) -> Iterable<R> ): List<R> ``` ``` inline fun <R> IntArray.flatMap(     transform: (Int) -> Iterable<R> ): List<R> ``` ``` inline fun <R> LongArray.flatMap(     transform: (Long) -> Iterable<R> ): List<R> ``` ``` inline fun <R> FloatArray.flatMap(     transform: (Float) -> Iterable<R> ): List<R> ``` ``` inline fun <R> DoubleArray.flatMap(     transform: (Double) -> Iterable<R> ): List<R> ``` ``` inline fun <R> BooleanArray.flatMap(     transform: (Boolean) -> Iterable<R> ): List<R> ``` ``` inline fun <R> CharArray.flatMap(     transform: (Char) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapSequence") inline fun <T, R> Array<out T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.flatMap(     transform: (UInt) -> Iterable<R> ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.flatMap(     transform: (ULong) -> Iterable<R> ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.flatMap(     transform: (UByte) -> Iterable<R> ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.flatMap(     transform: (UShort) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.collections%24flatMap(kotlin.Array((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("123", "45") println(list.flatMap { it.toList() }) // [1, 2, 3, 4, 5] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` @JvmName("flatMapSequence") inline fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("123", "45") println(list.flatMap { it.toList() }) // [1, 2, 3, 4, 5] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mapOf("122" to 2, "3455" to 3) println(map.flatMap { (key, value) -> key.take(value).toList() }) // [1, 2, 3, 4, 5] //sampleEnd } ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("flatMapSequence") inline fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Sequence<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.sequences.Sequence((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("123", "45") println(list.flatMap { it.toList() }) // [1, 2, 3, 4, 5] //sampleEnd } ``` kotlin minBy minBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minBy](min-by) **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <T, R : Comparable<R>> Array<out T>.minBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <T, R : Comparable<R>> Array<out T>.minBy(     selector: (T) -> R ): T? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> ByteArray.minBy(     selector: (Byte) -> R ): Byte ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> ByteArray.minBy(     selector: (Byte) -> R ): Byte? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> ShortArray.minBy(     selector: (Short) -> R ): Short ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> ShortArray.minBy(     selector: (Short) -> R ): Short? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> IntArray.minBy(     selector: (Int) -> R ): Int ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> IntArray.minBy(     selector: (Int) -> R ): Int? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> LongArray.minBy(     selector: (Long) -> R ): Long ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> LongArray.minBy(     selector: (Long) -> R ): Long? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> FloatArray.minBy(     selector: (Float) -> R ): Float ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> FloatArray.minBy(     selector: (Float) -> R ): Float? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> DoubleArray.minBy(     selector: (Double) -> R ): Double ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> DoubleArray.minBy(     selector: (Double) -> R ): Double? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> BooleanArray.minBy(     selector: (Boolean) -> R ): Boolean ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> BooleanArray.minBy(     selector: (Boolean) -> R ): Boolean? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> CharArray.minBy(     selector: (Char) -> R ): Char ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> CharArray.minBy(     selector: (Char) -> R ): Char? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.minBy(     selector: (UInt) -> R ): UInt ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.minBy(     selector: (UInt) -> R ): UInt? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.minBy(     selector: (ULong) -> R ): ULong ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.minBy(     selector: (ULong) -> R ): ULong? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.minBy(     selector: (UByte) -> R ): UByte ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.minBy(     selector: (UByte) -> R ): UByte? ``` **Deprecated:** Use minByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.minBy(     selector: (UShort) -> R ): UShort ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.minBy(     selector: (UShort) -> R ): UShort? ``` **Deprecated:** Use minByOrNull instead. Returns the first element yielding the smallest value of the given function. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.minBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <T, R : Comparable<R>> Iterable<T>.minBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <T, R : Comparable<R>> Iterable<T>.minBy(     selector: (T) -> R ): T? ``` **Deprecated:** Use minByOrNull instead. Returns the first element yielding the smallest value of the given function. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.minBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(     selector: (Entry<K, V>) -> R ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Deprecated:** Use minByOrNull instead. Returns the first entry yielding the smallest value of the given function. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.minBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the map is empty.
programming_docs
kotlin toByteArray toByteArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toByteArray](to-byte-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Array<out Byte>.toByteArray(): ByteArray ``` Returns an array of Byte containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Collection<Byte>.toByteArray(): ByteArray ``` Returns an array of Byte containing all of the elements of this collection. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UByteArray.toByteArray(): ByteArray ``` Returns an array of type [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. kotlin toUShortArray toUShortArray ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toUShortArray](to-u-short-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun Array<out UShort>.toUShortArray(): UShortArray ``` Returns an array of UShort containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ShortArray.toUShortArray(): UShortArray ``` Returns an array of type [UShortArray](../kotlin/-u-short-array/index), which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun Collection<UShort>.toUShortArray(): UShortArray ``` Returns an array of UShort containing all of the elements of this collection. kotlin Iterable Iterable ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [Iterable](-iterable) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Iterable(     crossinline iterator: () -> Iterator<T> ): Iterable<T> ``` Given an [iterator](-iterable#kotlin.collections%24Iterable(kotlin.Function0((kotlin.collections.Iterator((kotlin.collections.Iterable.T)))))/iterator) function constructs an [Iterable](-iterable/index#kotlin.collections.Iterable) instance that returns values through the [Iterator](-iterator/index#kotlin.collections.Iterator) provided by that function. ``` fun main(args: Array<String>) { //sampleStart val iterable = Iterable { iterator { yield(42) yieldAll(1..5 step 2) } } val result = iterable.mapIndexed { index, value -> "$index: $value" } println(result) // [0: 42, 1: 1, 2: 3, 3: 5] // can be iterated many times repeat(2) { val sum = iterable.sum() println(sum) // 51 } //sampleEnd } ``` kotlin dropWhile dropWhile ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [dropWhile](drop-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` inline fun ByteArray.dropWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` inline fun ShortArray.dropWhile(     predicate: (Short) -> Boolean ): List<Short> ``` ``` inline fun IntArray.dropWhile(     predicate: (Int) -> Boolean ): List<Int> ``` ``` inline fun LongArray.dropWhile(     predicate: (Long) -> Boolean ): List<Long> ``` ``` inline fun FloatArray.dropWhile(     predicate: (Float) -> Boolean ): List<Float> ``` ``` inline fun DoubleArray.dropWhile(     predicate: (Double) -> Boolean ): List<Double> ``` ``` inline fun BooleanArray.dropWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.dropWhile(     predicate: (Char) -> Boolean ): List<Char> ``` ``` inline fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.dropWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.dropWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.dropWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.dropWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` Returns a list containing all elements except first elements that satisfy the given [predicate](drop-while#kotlin.collections%24dropWhile(kotlin.Array((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.drop(23)) // [x, y, z] println(chars.dropLast(23)) // [a, b, c] println(chars.dropWhile { it < 'x' }) // [x, y, z] println(chars.dropLastWhile { it > 'c' }) // [a, b, c] //sampleEnd } ``` kotlin minusElement minusElement ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minusElement](minus-element) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` Returns a list containing all elements of the original collection without the first occurrence of the given [element](minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Set<T>.minusElement(element: T): Set<T> ``` Returns a set containing all elements of the original set except the given [element](minus-element#kotlin.collections%24minusElement(kotlin.collections.Set((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). The returned set preserves the element iteration order of the original set. kotlin find find ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <find> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.find(     predicate: (T) -> Boolean ): T? ``` ``` inline fun ByteArray.find(     predicate: (Byte) -> Boolean ): Byte? ``` ``` inline fun ShortArray.find(     predicate: (Short) -> Boolean ): Short? ``` ``` inline fun IntArray.find(predicate: (Int) -> Boolean): Int? ``` ``` inline fun LongArray.find(     predicate: (Long) -> Boolean ): Long? ``` ``` inline fun FloatArray.find(     predicate: (Float) -> Boolean ): Float? ``` ``` inline fun DoubleArray.find(     predicate: (Double) -> Boolean ): Double? ``` ``` inline fun BooleanArray.find(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.find(     predicate: (Char) -> Boolean ): Char? ``` ``` inline fun <T> Iterable<T>.find(     predicate: (T) -> Boolean ): T? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.find(     predicate: (UInt) -> Boolean ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.find(     predicate: (ULong) -> Boolean ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.find(     predicate: (UByte) -> Boolean ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.find(     predicate: (UShort) -> Boolean ): UShort? ``` Returns the first element matching the given [predicate](find#kotlin.collections%24find(kotlin.Array((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3, 4, 5, 6, 7) val firstOdd = numbers.find { it % 2 != 0 } val lastEven = numbers.findLast { it % 2 == 0 } println(firstOdd) // 1 println(lastEven) // 6 //sampleEnd } ``` kotlin takeLastWhile takeLastWhile ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [takeLastWhile](take-last-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` inline fun ByteArray.takeLastWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` inline fun ShortArray.takeLastWhile(     predicate: (Short) -> Boolean ): List<Short> ``` ``` inline fun IntArray.takeLastWhile(     predicate: (Int) -> Boolean ): List<Int> ``` ``` inline fun LongArray.takeLastWhile(     predicate: (Long) -> Boolean ): List<Long> ``` ``` inline fun FloatArray.takeLastWhile(     predicate: (Float) -> Boolean ): List<Float> ``` ``` inline fun DoubleArray.takeLastWhile(     predicate: (Double) -> Boolean ): List<Double> ``` ``` inline fun BooleanArray.takeLastWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.takeLastWhile(     predicate: (Char) -> Boolean ): List<Char> ``` ``` inline fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.takeLastWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.takeLastWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.takeLastWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.takeLastWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` Returns a list containing last elements satisfying the given [predicate](take-last-while#kotlin.collections%24takeLastWhile(kotlin.Array((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.take(3)) // [a, b, c] println(chars.takeWhile { it < 'f' }) // [a, b, c, d, e] println(chars.takeLast(2)) // [y, z] println(chars.takeLastWhile { it > 'w' }) // [x, y, z] //sampleEnd } ``` kotlin elementAtOrNull elementAtOrNull =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [elementAtOrNull](element-at-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.elementAtOrNull(index: Int): T? ``` ``` fun ByteArray.elementAtOrNull(index: Int): Byte? ``` ``` fun ShortArray.elementAtOrNull(index: Int): Short? ``` ``` fun IntArray.elementAtOrNull(index: Int): Int? ``` ``` fun LongArray.elementAtOrNull(index: Int): Long? ``` ``` fun FloatArray.elementAtOrNull(index: Int): Float? ``` ``` fun DoubleArray.elementAtOrNull(index: Int): Double? ``` ``` fun BooleanArray.elementAtOrNull(index: Int): Boolean? ``` ``` fun CharArray.elementAtOrNull(index: Int): Char? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.elementAtOrNull(     index: Int ): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.elementAtOrNull(     index: Int ): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.elementAtOrNull(     index: Int ): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.elementAtOrNull(     index: Int ): UShort? ``` Returns an element at the given [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.Array((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.Array((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrNull(0)) // 1 println(list.elementAtOrNull(2)) // 3 println(list.elementAtOrNull(3)) // null val emptyList = emptyList<Int>() println(emptyList.elementAtOrNull(0)) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` Returns an element at the given [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrNull(0)) // 1 println(list.elementAtOrNull(2)) // 3 println(list.elementAtOrNull(3)) // null val emptyList = emptyList<Int>() println(emptyList.elementAtOrNull(0)) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.elementAtOrNull(index: Int): T? ``` Returns an element at the given [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.List((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.List((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrNull(0)) // 1 println(list.elementAtOrNull(2)) // 3 println(list.elementAtOrNull(3)) // null val emptyList = emptyList<Int>() println(emptyList.elementAtOrNull(0)) // null //sampleEnd } ``` kotlin eachCount eachCount ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [eachCount](each-count) **Platform and version requirements:** JVM (1.1), JS (1.1) ``` fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int> ``` Groups elements from the Grouping source by key and counts elements in each group. ``` fun main(args: Array<String>) { //sampleStart val words = "one two three four five six seven eight nine ten".split(' ') val frequenciesByFirstChar = words.groupingBy { it.first() }.eachCount() println("Counting first letters:") println(frequenciesByFirstChar) // {o=1, t=3, f=2, s=2, e=1, n=1} val moreWords = "eleven twelve".split(' ') val moreFrequencies = moreWords.groupingBy { it.first() }.eachCountTo(frequenciesByFirstChar.toMutableMap()) println(moreFrequencies) // {o=1, t=4, f=2, s=2, e=2, n=1} //sampleEnd } ``` **Return** a [Map](-map/index#kotlin.collections.Map) associating the key of each group with the count of elements in the group. kotlin filterValues filterValues ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterValues](filter-values) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.filterValues(     predicate: (V) -> Boolean ): Map<K, V> ``` Returns a map containing all key-value pairs with values matching the given [predicate](filter-values#kotlin.collections%24filterValues(kotlin.collections.Map((kotlin.collections.filterValues.K,%20kotlin.collections.filterValues.V)),%20kotlin.Function1((kotlin.collections.filterValues.V,%20kotlin.Boolean)))/predicate). The returned map preserves the entry iteration order of the original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val originalMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3) val filteredMap = originalMap.filterValues { it >= 2 } println(filteredMap) // {key2=2, key3=3} // original map has not changed println(originalMap) // {key1=1, key2=2, key3=3} val nonMatchingPredicate: (Int) -> Boolean = { it == 0 } val emptyMap = originalMap.filterValues(nonMatchingPredicate) println(emptyMap) // {} //sampleEnd } ``` kotlin isNotEmpty isNotEmpty ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [isNotEmpty](is-not-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.isNotEmpty(): Boolean ``` ``` fun ByteArray.isNotEmpty(): Boolean ``` ``` fun ShortArray.isNotEmpty(): Boolean ``` ``` fun IntArray.isNotEmpty(): Boolean ``` ``` fun LongArray.isNotEmpty(): Boolean ``` ``` fun FloatArray.isNotEmpty(): Boolean ``` ``` fun DoubleArray.isNotEmpty(): Boolean ``` ``` fun BooleanArray.isNotEmpty(): Boolean ``` ``` fun CharArray.isNotEmpty(): Boolean ``` Returns `true` if the array is not empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` Returns `true` if the collection is not empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val empty = emptyList<Any>() println("empty.isNotEmpty() is ${empty.isNotEmpty()}") // false val collection = listOf('a', 'b', 'c') println("collection.isNotEmpty() is ${collection.isNotEmpty()}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<out K, V>.isNotEmpty(): Boolean ``` Returns `true` if this map is not empty. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart fun totalValue(statisticsMap: Map<String, Int>): String = when { statisticsMap.isNotEmpty() -> { val total = statisticsMap.values.sum() "Total: [$total]" } else -> "<No values>" } val emptyStats: Map<String, Int> = mapOf() println(totalValue(emptyStats)) // <No values> val stats: Map<String, Int> = mapOf("Store #1" to 1247, "Store #2" to 540) println(totalValue(stats)) // Total: [1787] //sampleEnd } ``` kotlin unzip unzip ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <unzip> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, R> Array<out Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` Returns a pair of lists, where *first* list is built from the first values of each pair from this array, *second* list is built from the second values of each pair from this array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf(1 to 'a', 2 to 'b', 3 to 'c') println(array.unzip()) // ([1, 2, 3], [a, b, c]) //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun main(args: Array<String>) { //sampleStart val list = listOf(1 to 'a', 2 to 'b', 3 to 'c') println(list.unzip()) // ([1, 2, 3], [a, b, c]) //sampleEnd } ``` kotlin filterKeys filterKeys ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterKeys](filter-keys) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.filterKeys(     predicate: (K) -> Boolean ): Map<K, V> ``` Returns a map containing all key-value pairs with keys matching the given [predicate](filter-keys#kotlin.collections%24filterKeys(kotlin.collections.Map((kotlin.collections.filterKeys.K,%20kotlin.collections.filterKeys.V)),%20kotlin.Function1((kotlin.collections.filterKeys.K,%20kotlin.Boolean)))/predicate). The returned map preserves the entry iteration order of the original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val originalMap = mapOf("key1" to 1, "key2" to 2, "something_else" to 3) val filteredMap = originalMap.filterKeys { it.contains("key") } println(filteredMap) // {key1=1, key2=2} // original map has not changed println(originalMap) // {key1=1, key2=2, something_else=3} val nonMatchingPredicate: (String) -> Boolean = { it == "key3" } val emptyMap = originalMap.filterKeys(nonMatchingPredicate) println(emptyMap) // {} //sampleEnd } ```
programming_docs
kotlin contentDeepHashCode contentDeepHashCode =================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [contentDeepHashCode](content-deep-hash-code) **Platform and version requirements:** JS (1.1), Native (1.1) ``` fun <T> Array<out T>.contentDeepHashCode(): Int ``` **Platform and version requirements:** JVM (1.1) ``` @JvmName("contentDeepHashCodeInline") fun <T> Array<out T>.contentDeepHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun <T> Array<out T>?.contentDeepHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentDeepHashCodeNullable") fun <T> Array<out T>?.contentDeepHashCode(): Int ``` Returns a hash code based on the contents of this array as if it is [List](-list/index#kotlin.collections.List). Nested arrays are treated as lists too. If any of arrays contains itself on any nesting level the behavior is undefined. kotlin linkedMapOf linkedMapOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [linkedMapOf](linked-map-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <K, V> linkedMapOf(): LinkedHashMap<K, V> ``` Returns an empty new [LinkedHashMap](-linked-hash-map/index#kotlin.collections.LinkedHashMap). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> linkedMapOf(     vararg pairs: Pair<K, V> ): LinkedHashMap<K, V> ``` Returns a new [LinkedHashMap](-linked-hash-map/index#kotlin.collections.LinkedHashMap) with the specified contents, given as a list of pairs where the first component is the key and the second is the value. If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs. Entries of the map are iterated in the order they were specified. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map: LinkedHashMap<Int, String> = linkedMapOf(1 to "x", 2 to "y", -1 to "zz") println(map) // {1=x, 2=y, -1=zz} //sampleEnd } ``` kotlin maxBy maxBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxBy](max-by) **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <T, R : Comparable<R>> Array<out T>.maxBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <T, R : Comparable<R>> Array<out T>.maxBy(     selector: (T) -> R ): T? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> ByteArray.maxBy(     selector: (Byte) -> R ): Byte ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> ByteArray.maxBy(     selector: (Byte) -> R ): Byte? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> ShortArray.maxBy(     selector: (Short) -> R ): Short ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> ShortArray.maxBy(     selector: (Short) -> R ): Short? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> IntArray.maxBy(     selector: (Int) -> R ): Int ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> IntArray.maxBy(     selector: (Int) -> R ): Int? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> LongArray.maxBy(     selector: (Long) -> R ): Long ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> LongArray.maxBy(     selector: (Long) -> R ): Long? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> FloatArray.maxBy(     selector: (Float) -> R ): Float ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> FloatArray.maxBy(     selector: (Float) -> R ): Float? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> DoubleArray.maxBy(     selector: (Double) -> R ): Double ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> DoubleArray.maxBy(     selector: (Double) -> R ): Double? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> BooleanArray.maxBy(     selector: (Boolean) -> R ): Boolean ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> BooleanArray.maxBy(     selector: (Boolean) -> R ): Boolean? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> CharArray.maxBy(     selector: (Char) -> R ): Char ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> CharArray.maxBy(     selector: (Char) -> R ): Char? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.maxBy(     selector: (UInt) -> R ): UInt ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.maxBy(     selector: (UInt) -> R ): UInt? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.maxBy(     selector: (ULong) -> R ): ULong ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.maxBy(     selector: (ULong) -> R ): ULong? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.maxBy(     selector: (UByte) -> R ): UByte ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.maxBy(     selector: (UByte) -> R ): UByte? ``` **Deprecated:** Use maxByOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.maxBy(     selector: (UShort) -> R ): UShort ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.maxBy(     selector: (UShort) -> R ): UShort? ``` **Deprecated:** Use maxByOrNull instead. Returns the first element yielding the largest value of the given function. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.maxBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(     selector: (T) -> R ): T? ``` **Deprecated:** Use maxByOrNull instead. Returns the first element yielding the largest value of the given function. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.maxBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(     selector: (Entry<K, V>) -> R ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Deprecated:** Use maxByOrNull instead. Returns the first entry yielding the largest value of the given function. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.maxBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the map is empty. kotlin asULongArray asULongArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asULongArray](as-u-long-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun LongArray.asULongArray(): ULongArray ``` Returns an array of type [ULongArray](../kotlin/-u-long-array/index), which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array. kotlin getOrElse getOrElse ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [getOrElse](get-or-else) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` ``` inline fun ByteArray.getOrElse(     index: Int,     defaultValue: (Int) -> Byte ): Byte ``` ``` inline fun ShortArray.getOrElse(     index: Int,     defaultValue: (Int) -> Short ): Short ``` ``` inline fun IntArray.getOrElse(     index: Int,     defaultValue: (Int) -> Int ): Int ``` ``` inline fun LongArray.getOrElse(     index: Int,     defaultValue: (Int) -> Long ): Long ``` ``` inline fun FloatArray.getOrElse(     index: Int,     defaultValue: (Int) -> Float ): Float ``` ``` inline fun DoubleArray.getOrElse(     index: Int,     defaultValue: (Int) -> Double ): Double ``` ``` inline fun BooleanArray.getOrElse(     index: Int,     defaultValue: (Int) -> Boolean ): Boolean ``` ``` inline fun CharArray.getOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.getOrElse(     index: Int,     defaultValue: (Int) -> UInt ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.getOrElse(     index: Int,     defaultValue: (Int) -> ULong ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.getOrElse(     index: Int,     defaultValue: (Int) -> UByte ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.getOrElse(     index: Int,     defaultValue: (Int) -> UShort ): UShort ``` Returns an element at the given [index](get-or-else#kotlin.collections%24getOrElse(kotlin.Array((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](get-or-else#kotlin.collections%24getOrElse(kotlin.Array((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](get-or-else#kotlin.collections%24getOrElse(kotlin.Array((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<K, V>.getOrElse(     key: K,     defaultValue: () -> V ): V ``` Returns the value for the given [key](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/key) if the value is present and not `null`. Otherwise, returns the result of the [defaultValue](get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/defaultValue) function. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mutableMapOf<String, Int?>() println(map.getOrElse("x") { 1 }) // 1 map["x"] = 3 println(map.getOrElse("x") { 1 }) // 3 map["x"] = null println(map.getOrElse("x") { 1 }) // 1 //sampleEnd } ``` kotlin toSortedMap toSortedMap =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toSortedMap](to-sorted-map) **Platform and version requirements:** JVM (1.0) ``` fun <K : Comparable<K>, V> Map<out K, V>.toSortedMap(): SortedMap<K, V> ``` Converts this [Map](-map/index#kotlin.collections.Map) to a [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to their natural sorting order. Note that if the natural sorting order of keys considers any two keys of this map equal (this could happen if the equality of keys according to [Comparable.compareTo](../kotlin/-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)) is inconsistent with the equality according to [Any.equals](../kotlin/-any/equals#kotlin.Any%24equals(kotlin.Any?))), only the value associated with the last of them gets into the resulting map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mapOf(Pair("c", 3), Pair("b", 2), Pair("d", 1)) val sorted = map.toSortedMap() println(sorted.keys) // [b, c, d] println(sorted.values) // [2, 3, 1] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V> Map<out K, V>.toSortedMap(     comparator: Comparator<in K> ): SortedMap<K, V> ``` Converts this [Map](-map/index#kotlin.collections.Map) to a [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to the sorting order provided by the given [comparator](to-sorted-map#kotlin.collections%24toSortedMap(kotlin.collections.Map((kotlin.collections.toSortedMap.K,%20kotlin.collections.toSortedMap.V)),%20java.util.Comparator((kotlin.collections.toSortedMap.K)))/comparator). Note that if the `comparator` considers any two keys of this map equal, only the value associated with the last of them gets into the resulting map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mapOf(Pair("abc", 1), Pair("c", 3), Pair("bd", 4), Pair("bc", 2)) val sorted = map.toSortedMap(compareBy<String> { it.length }.thenBy { it }) println(sorted.keys) // [c, bc, bd, abc] //sampleEnd } ``` kotlin requireNoNulls requireNoNulls ============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [requireNoNulls](require-no-nulls) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> Array<T?>.requireNoNulls(): Array<T> ``` ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` ``` fun <T : Any> List<T?>.requireNoNulls(): List<T> ``` Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. kotlin random random ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <random> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Array<out T>.random(): T ``` ``` fun ByteArray.random(): Byte ``` ``` fun ShortArray.random(): Short ``` ``` fun IntArray.random(): Int ``` ``` fun LongArray.random(): Long ``` ``` fun FloatArray.random(): Float ``` ``` fun DoubleArray.random(): Double ``` ``` fun BooleanArray.random(): Boolean ``` ``` fun CharArray.random(): Char ``` ``` @ExperimentalUnsignedTypes fun UIntArray.random(): UInt ``` ``` @ExperimentalUnsignedTypes fun ULongArray.random(): ULong ``` ``` @ExperimentalUnsignedTypes fun UByteArray.random(): UByte ``` ``` @ExperimentalUnsignedTypes fun UShortArray.random(): UShort ``` Returns a random element from this array. Exceptions ---------- `NoSuchElementException` - if this array is empty. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Array<out T>.random(random: Random): T ``` ``` fun ByteArray.random(random: Random): Byte ``` ``` fun ShortArray.random(random: Random): Short ``` ``` fun IntArray.random(random: Random): Int ``` ``` fun LongArray.random(random: Random): Long ``` ``` fun FloatArray.random(random: Random): Float ``` ``` fun DoubleArray.random(random: Random): Double ``` ``` fun BooleanArray.random(random: Random): Boolean ``` ``` fun CharArray.random(random: Random): Char ``` ``` @ExperimentalUnsignedTypes fun UIntArray.random(     random: Random ): UInt ``` ``` @ExperimentalUnsignedTypes fun ULongArray.random(     random: Random ): ULong ``` ``` @ExperimentalUnsignedTypes fun UByteArray.random(     random: Random ): UByte ``` ``` @ExperimentalUnsignedTypes fun UShortArray.random(     random: Random ): UShort ``` Returns a random element from this array using the specified source of randomness. Exceptions ---------- `NoSuchElementException` - if this array is empty. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection. Exceptions ---------- `NoSuchElementException` - if this collection is empty. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Collection<T>.random(random: Random): T ``` Returns a random element from this collection using the specified source of randomness. Exceptions ---------- `NoSuchElementException` - if this collection is empty.
programming_docs
kotlin sumBy sumBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sumBy](sum-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") inline fun <T> Array<out T>.sumBy(     selector: (T) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun ByteArray.sumBy(     selector: (Byte) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun ShortArray.sumBy(     selector: (Short) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun IntArray.sumBy(     selector: (Int) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun LongArray.sumBy(     selector: (Long) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun FloatArray.sumBy(     selector: (Float) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun DoubleArray.sumBy(     selector: (Double) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun BooleanArray.sumBy(     selector: (Boolean) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") inline fun CharArray.sumBy(     selector: (Char) -> Int ): Int ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") @ExperimentalUnsignedTypes inline fun UIntArray.sumBy(     selector: (UInt) -> UInt ): UInt ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") @ExperimentalUnsignedTypes inline fun ULongArray.sumBy(     selector: (ULong) -> UInt ): UInt ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") @ExperimentalUnsignedTypes inline fun UByteArray.sumBy(     selector: (UByte) -> UInt ): UInt ``` **Deprecated:** Use sumOf instead. ``` @DeprecatedSinceKotlin("1.5") @ExperimentalUnsignedTypes inline fun UShortArray.sumBy(     selector: (UShort) -> UInt ): UInt ``` **Deprecated:** Use sumOf instead. Returns the sum of all values produced by [selector](sum-by#kotlin.collections%24sumBy(kotlin.Array((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") inline fun <T> Iterable<T>.sumBy(     selector: (T) -> Int ): Int ``` **Deprecated:** Use sumOf instead. Returns the sum of all values produced by [selector](sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. kotlin List List ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [List](-list) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T> List(     size: Int,     init: (index: Int) -> T ): List<T> ``` Creates a new read-only list with the specified [size](-list#kotlin.collections%24List(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.List.T)))/size), where each element is calculated by calling the specified [init](-list#kotlin.collections%24List(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.List.T)))/init) function. The function [init](-list#kotlin.collections%24List(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.List.T)))/init) is called for each list element sequentially starting from the first one. It should return the value for a list element given its index. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val squares = List(5) { (it + 1) * (it + 1) } println(squares) // [1, 4, 9, 16, 25] //sampleEnd } ``` kotlin reduce reduce ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <reduce> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> Array<out T>.reduce(     operation: (acc: S, T) -> S ): S ``` ``` inline fun ByteArray.reduce(     operation: (acc: Byte, Byte) -> Byte ): Byte ``` ``` inline fun ShortArray.reduce(     operation: (acc: Short, Short) -> Short ): Short ``` ``` inline fun IntArray.reduce(     operation: (acc: Int, Int) -> Int ): Int ``` ``` inline fun LongArray.reduce(     operation: (acc: Long, Long) -> Long ): Long ``` ``` inline fun FloatArray.reduce(     operation: (acc: Float, Float) -> Float ): Float ``` ``` inline fun DoubleArray.reduce(     operation: (acc: Double, Double) -> Double ): Double ``` ``` inline fun BooleanArray.reduce(     operation: (acc: Boolean, Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.reduce(     operation: (acc: Char, Char) -> Char ): Char ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.reduce(     operation: (acc: UInt, UInt) -> UInt ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.reduce(     operation: (acc: ULong, ULong) -> ULong ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.reduce(     operation: (acc: UByte, UByte) -> UByte ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.reduce(     operation: (acc: UShort, UShort) -> UShort ): UShort ``` Accumulates value starting with the first element and applying [operation](reduce#kotlin.collections%24reduce(kotlin.Array((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. Throws an exception if this array is empty. If the array can be empty in an expected way, please use [reduceOrNull](reduce-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduce { acc, string -> acc + string }) // abcd println(strings.reduceIndexed { index, acc, string -> acc + string + index }) // ab1c2d3 // emptyList<Int>().reduce { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` Accumulates value starting with the first element and applying [operation](reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. Throws an exception if this collection is empty. If the collection can be empty in an expected way, please use [reduceOrNull](reduce-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduce { acc, string -> acc + string }) // abcd println(strings.reduceIndexed { index, acc, string -> acc + string + index }) // ab1c2d3 // emptyList<Int>().reduce { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <S, T : S, K> Grouping<T, K>.reduce(     operation: (key: K, accumulator: S, element: T) -> S ): Map<K, S> ``` Groups elements from the [Grouping](-grouping/index) source by key and applies the reducing [operation](reduce#kotlin.collections%24reduce(kotlin.collections.Grouping((kotlin.collections.reduce.T,%20kotlin.collections.reduce.K)),%20kotlin.Function3((kotlin.collections.reduce.K,%20kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the first element of the group. ``` fun main(args: Array<String>) { //sampleStart val animals = listOf("raccoon", "reindeer", "cow", "camel", "giraffe", "goat") // grouping by first char and collect only max of contains vowels val compareByVowelCount = compareBy { s: String -> s.count { it in "aeiou" } } val maxVowels = animals.groupingBy { it.first() }.reduce { _, a, b -> maxOf(a, b, compareByVowelCount) } println(maxVowels) // {r=reindeer, c=camel, g=giraffe} //sampleEnd } ``` Parameters ---------- `operation` - a function that is invoked on each subsequent element of the group with the following parameters: **Return** a [Map](-map/index#kotlin.collections.Map) associating the key of each group with the result of accumulating the group elements. kotlin component3 component3 ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <component3> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Array<out T>.component3(): T ``` ``` operator fun ByteArray.component3(): Byte ``` ``` operator fun ShortArray.component3(): Short ``` ``` operator fun IntArray.component3(): Int ``` ``` operator fun LongArray.component3(): Long ``` ``` operator fun FloatArray.component3(): Float ``` ``` operator fun DoubleArray.component3(): Double ``` ``` operator fun BooleanArray.component3(): Boolean ``` ``` operator fun CharArray.component3(): Char ``` ``` @ExperimentalUnsignedTypes operator fun UIntArray.component3(): UInt ``` ``` @ExperimentalUnsignedTypes operator fun ULongArray.component3(): ULong ``` ``` @ExperimentalUnsignedTypes operator fun UByteArray.component3(): UByte ``` ``` @ExperimentalUnsignedTypes operator fun UShortArray.component3(): UShort ``` Returns 3rd *element* from the array. If the size of this array is less than 3, throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) except in Kotlin/JS where the behavior is unspecified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> List<T>.component3(): T ``` Returns 3rd *element* from the list. Throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the size of this list is less than 3. kotlin contentEquals contentEquals ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [contentEquals](content-equals) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun <T> Array<out T>.contentEquals(     other: Array<out T> ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun ByteArray.contentEquals(     other: ByteArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun ShortArray.contentEquals(     other: ShortArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun IntArray.contentEquals(     other: IntArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun LongArray.contentEquals(     other: LongArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun FloatArray.contentEquals(     other: FloatArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun DoubleArray.contentEquals(     other: DoubleArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun BooleanArray.contentEquals(     other: BooleanArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") infix fun CharArray.contentEquals(     other: CharArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun <T> Array<out T>?.contentEquals(     other: Array<out T>? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun <T> Array<out T>?.contentEquals(     other: Array<out T>? ): Boolean ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun ByteArray?.contentEquals(     other: ByteArray? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun ByteArray?.contentEquals(     other: ByteArray? ): Boolean ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun ShortArray?.contentEquals(     other: ShortArray? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun ShortArray?.contentEquals(     other: ShortArray? ): Boolean ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun IntArray?.contentEquals(other: IntArray?): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun IntArray?.contentEquals(     other: IntArray? ): Boolean ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun LongArray?.contentEquals(     other: LongArray? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun LongArray?.contentEquals(     other: LongArray? ): Boolean ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun FloatArray?.contentEquals(     other: FloatArray? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun FloatArray?.contentEquals(     other: FloatArray? ): Boolean ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun DoubleArray?.contentEquals(     other: DoubleArray? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun DoubleArray?.contentEquals(     other: DoubleArray? ): Boolean ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun BooleanArray?.contentEquals(     other: BooleanArray? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun BooleanArray?.contentEquals(     other: BooleanArray? ): Boolean ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun CharArray?.contentEquals(     other: CharArray? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentEqualsNullable") infix fun CharArray?.contentEquals(     other: CharArray? ): Boolean ``` Returns `true` if the two specified arrays are *structurally* equal to one another, i.e. contain the same number of the same elements in the same order. The elements are compared for equality with the [equals](../kotlin/-any/equals#kotlin.Any%24equals(kotlin.Any?)) function. For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes infix fun UIntArray.contentEquals(     other: UIntArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes infix fun ULongArray.contentEquals(     other: ULongArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes infix fun UByteArray.contentEquals(     other: UByteArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes infix fun UShortArray.contentEquals(     other: UShortArray ): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @ExperimentalUnsignedTypes infix fun UIntArray?.contentEquals(     other: UIntArray? ): Boolean ``` ``` @ExperimentalUnsignedTypes infix fun ULongArray?.contentEquals(     other: ULongArray? ): Boolean ``` ``` @ExperimentalUnsignedTypes infix fun UByteArray?.contentEquals(     other: UByteArray? ): Boolean ``` ``` @ExperimentalUnsignedTypes infix fun UShortArray?.contentEquals(     other: UShortArray? ): Boolean ``` Returns `true` if the two specified arrays are *structurally* equal to one another, i.e. contain the same number of the same elements in the same order. kotlin slice slice ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <slice> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.slice(indices: IntRange): List<T> ``` ``` fun ByteArray.slice(indices: IntRange): List<Byte> ``` ``` fun ShortArray.slice(indices: IntRange): List<Short> ``` ``` fun IntArray.slice(indices: IntRange): List<Int> ``` ``` fun LongArray.slice(indices: IntRange): List<Long> ``` ``` fun FloatArray.slice(indices: IntRange): List<Float> ``` ``` fun DoubleArray.slice(indices: IntRange): List<Double> ``` ``` fun BooleanArray.slice(indices: IntRange): List<Boolean> ``` ``` fun CharArray.slice(indices: IntRange): List<Char> ``` ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.slice(     indices: IntRange ): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.slice(     indices: IntRange ): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.slice(     indices: IntRange ): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.slice(     indices: IntRange ): List<UShort> ``` Returns a list containing elements at indices in the specified [indices](slice#kotlin.collections%24slice(kotlin.Array((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.slice(indices: Iterable<Int>): List<T> ``` ``` fun ByteArray.slice(indices: Iterable<Int>): List<Byte> ``` ``` fun ShortArray.slice(indices: Iterable<Int>): List<Short> ``` ``` fun IntArray.slice(indices: Iterable<Int>): List<Int> ``` ``` fun LongArray.slice(indices: Iterable<Int>): List<Long> ``` ``` fun FloatArray.slice(indices: Iterable<Int>): List<Float> ``` ``` fun DoubleArray.slice(indices: Iterable<Int>): List<Double> ``` ``` fun BooleanArray.slice(indices: Iterable<Int>): List<Boolean> ``` ``` fun CharArray.slice(indices: Iterable<Int>): List<Char> ``` ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.slice(     indices: Iterable<Int> ): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.slice(     indices: Iterable<Int> ): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.slice(     indices: Iterable<Int> ): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.slice(     indices: Iterable<Int> ): List<UShort> ``` Returns a list containing elements at specified [indices](slice#kotlin.collections%24slice(kotlin.Array((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices).
programming_docs
kotlin toCollection toCollection ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toCollection](to-collection) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, C : MutableCollection<in T>> Array<out T>.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Byte>> ByteArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Short>> ShortArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Int>> IntArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Long>> LongArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Float>> FloatArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Double>> DoubleArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Boolean>> BooleanArray.toCollection(     destination: C ): C ``` ``` fun <C : MutableCollection<in Char>> CharArray.toCollection(     destination: C ): C ``` ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` Appends all elements to the given [destination](to-collection#kotlin.collections%24toCollection(kotlin.Array((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. kotlin maxOfOrNull maxOfOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxOfOrNull](max-of-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Array<out T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` inline fun ByteArray.maxOfOrNull(     selector: (Byte) -> Double ): Double? ``` ``` inline fun ShortArray.maxOfOrNull(     selector: (Short) -> Double ): Double? ``` ``` inline fun IntArray.maxOfOrNull(     selector: (Int) -> Double ): Double? ``` ``` inline fun LongArray.maxOfOrNull(     selector: (Long) -> Double ): Double? ``` ``` inline fun FloatArray.maxOfOrNull(     selector: (Float) -> Double ): Double? ``` ``` inline fun DoubleArray.maxOfOrNull(     selector: (Double) -> Double ): Double? ``` ``` inline fun BooleanArray.maxOfOrNull(     selector: (Boolean) -> Double ): Double? ``` ``` inline fun CharArray.maxOfOrNull(     selector: (Char) -> Double ): Double? ``` ``` inline fun <T> Array<out T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` inline fun ByteArray.maxOfOrNull(     selector: (Byte) -> Float ): Float? ``` ``` inline fun ShortArray.maxOfOrNull(     selector: (Short) -> Float ): Float? ``` ``` inline fun IntArray.maxOfOrNull(     selector: (Int) -> Float ): Float? ``` ``` inline fun LongArray.maxOfOrNull(     selector: (Long) -> Float ): Float? ``` ``` inline fun FloatArray.maxOfOrNull(     selector: (Float) -> Float ): Float? ``` ``` inline fun DoubleArray.maxOfOrNull(     selector: (Double) -> Float ): Float? ``` ``` inline fun BooleanArray.maxOfOrNull(     selector: (Boolean) -> Float ): Float? ``` ``` inline fun CharArray.maxOfOrNull(     selector: (Char) -> Float ): Float? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.maxOfOrNull(     selector: (UInt) -> Double ): Double? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.maxOfOrNull(     selector: (ULong) -> Double ): Double? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.maxOfOrNull(     selector: (UByte) -> Double ): Double? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.maxOfOrNull(     selector: (UShort) -> Double ): Double? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.maxOfOrNull(     selector: (UInt) -> Float ): Float? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.maxOfOrNull(     selector: (ULong) -> Float ): Float? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.maxOfOrNull(     selector: (UByte) -> Float ): Float? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.maxOfOrNull(     selector: (UShort) -> Float ): Float? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.Array((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. If any of values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.Array((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Array<out T>.maxOfOrNull(     selector: (T) -> R ): R? ``` ``` inline fun <R : Comparable<R>> ByteArray.maxOfOrNull(     selector: (Byte) -> R ): R? ``` ``` inline fun <R : Comparable<R>> ShortArray.maxOfOrNull(     selector: (Short) -> R ): R? ``` ``` inline fun <R : Comparable<R>> IntArray.maxOfOrNull(     selector: (Int) -> R ): R? ``` ``` inline fun <R : Comparable<R>> LongArray.maxOfOrNull(     selector: (Long) -> R ): R? ``` ``` inline fun <R : Comparable<R>> FloatArray.maxOfOrNull(     selector: (Float) -> R ): R? ``` ``` inline fun <R : Comparable<R>> DoubleArray.maxOfOrNull(     selector: (Double) -> R ): R? ``` ``` inline fun <R : Comparable<R>> BooleanArray.maxOfOrNull(     selector: (Boolean) -> R ): R? ``` ``` inline fun <R : Comparable<R>> CharArray.maxOfOrNull(     selector: (Char) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.maxOfOrNull(     selector: (UInt) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.maxOfOrNull(     selector: (ULong) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.maxOfOrNull(     selector: (UByte) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.maxOfOrNull(     selector: (UShort) -> R ): R? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.Array((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.collections.maxOfOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` inline fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. If any of values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.collections.maxOfOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` inline fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. If any of values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.collections.maxOfOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. kotlin removeFirstOrNull removeFirstOrNull ================= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [removeFirstOrNull](remove-first-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> MutableList<T>.removeFirstOrNull(): T? ``` Removes the first element from this mutable list and returns that removed element, or returns `null` if this list is empty. kotlin firstNotNullOfOrNull firstNotNullOfOrNull ==================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [firstNotNullOfOrNull](first-not-null-of-or-null) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <T, R : Any> Array<out T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.Array((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this array in iteration order, or `null` if no non-null value was produced. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <K, V, R : Any> Map<out K, V>.firstNotNullOfOrNull(     transform: (Entry<K, V>) -> R? ): R? ``` Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Map((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to entries of this map in iteration order, or `null` if no non-null value was produced. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` kotlin subtract subtract ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <subtract> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T> Array<out T>.subtract(     other: Iterable<T> ): Set<T> ``` ``` infix fun ByteArray.subtract(     other: Iterable<Byte> ): Set<Byte> ``` ``` infix fun ShortArray.subtract(     other: Iterable<Short> ): Set<Short> ``` ``` infix fun IntArray.subtract(other: Iterable<Int>): Set<Int> ``` ``` infix fun LongArray.subtract(     other: Iterable<Long> ): Set<Long> ``` ``` infix fun FloatArray.subtract(     other: Iterable<Float> ): Set<Float> ``` ``` infix fun DoubleArray.subtract(     other: Iterable<Double> ): Set<Double> ``` ``` infix fun BooleanArray.subtract(     other: Iterable<Boolean> ): Set<Boolean> ``` ``` infix fun CharArray.subtract(     other: Iterable<Char> ): Set<Char> ``` Returns a set containing all elements that are contained by this array and not contained by the specified collection. The returned set preserves the element iteration order of the original array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` Returns a set containing all elements that are contained by this collection and not contained by the specified collection. The returned set preserves the element iteration order of the original collection. kotlin stringSetOf stringSetOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [stringSetOf](string-set-of) **Platform and version requirements:** JS (1.1) ``` fun stringSetOf(vararg elements: String): HashSet<String> ``` Creates a new instance of the specialized implementation of [HashSet](-hash-set/index#kotlin.collections.HashSet) with the specified String elements, which elements the keys as properties of JS object without hashing them. kotlin iterator iterator ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` import java.util.* fun main(args: Array<String>) { //sampleStart val mutableList = mutableListOf(1, 2, 3) val mutableIterator = mutableList.iterator() // iterator() extension is called here for (e in mutableIterator) { if (e % 2 == 0) { // we can remove items from the iterator without getting ConcurrentModificationException // because it's the same iterator that is iterated with for loop mutableIterator.remove() } println("The element is $e") } //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.iterator(): Iterator<Entry<K, V>> ``` Returns an [Iterator](-iterator/index#kotlin.collections.Iterator) over the entries in the [Map](-map/index#kotlin.collections.Map). ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mapOf("beverage" to 2.7, "meal" to 12.4, "dessert" to 5.8) for ((key, value) in map) { println("$key - $value") // prints: beverage - 2.7 // prints: meal - 12.4 // prints: dessert - 5.8 } //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("mutableIterator") operator fun <K, V> MutableMap<K, V>.iterator(): MutableIterator<MutableEntry<K, V>> ``` Returns a [MutableIterator](-mutable-iterator/index#kotlin.collections.MutableIterator) over the mutable entries in the [MutableMap](-mutable-map/index#kotlin.collections.MutableMap). kotlin minWith minWith ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minWith](min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("minWithOrThrow") fun <T> Array<out T>.minWith(     comparator: Comparator<in T> ): T ``` ``` @JvmName("minWithOrThrow") fun ByteArray.minWith(     comparator: Comparator<in Byte> ): Byte ``` ``` @JvmName("minWithOrThrow") fun ShortArray.minWith(     comparator: Comparator<in Short> ): Short ``` ``` @JvmName("minWithOrThrow") fun IntArray.minWith(     comparator: Comparator<in Int> ): Int ``` ``` @JvmName("minWithOrThrow") fun LongArray.minWith(     comparator: Comparator<in Long> ): Long ``` ``` @JvmName("minWithOrThrow") fun FloatArray.minWith(     comparator: Comparator<in Float> ): Float ``` ``` @JvmName("minWithOrThrow") fun DoubleArray.minWith(     comparator: Comparator<in Double> ): Double ``` ``` @JvmName("minWithOrThrow") fun BooleanArray.minWith(     comparator: Comparator<in Boolean> ): Boolean ``` ``` @JvmName("minWithOrThrow") fun CharArray.minWith(     comparator: Comparator<in Char> ): Char ``` ``` @JvmName("minWithOrThrow-U") @ExperimentalUnsignedTypes fun UIntArray.minWith(     comparator: Comparator<in UInt> ): UInt ``` ``` @JvmName("minWithOrThrow-U") @ExperimentalUnsignedTypes fun ULongArray.minWith(     comparator: Comparator<in ULong> ): ULong ``` ``` @JvmName("minWithOrThrow-U") @ExperimentalUnsignedTypes fun UByteArray.minWith(     comparator: Comparator<in UByte> ): UByte ``` ``` @JvmName("minWithOrThrow-U") @ExperimentalUnsignedTypes fun UShortArray.minWith(     comparator: Comparator<in UShort> ): UShort ``` Returns the first element having the smallest value according to the provided [comparator](min-with#kotlin.collections%24minWith(kotlin.Array((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("minWithOrThrow") fun <T> Iterable<T>.minWith(     comparator: Comparator<in T> ): T ``` Returns the first element having the smallest value according to the provided [comparator](min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("minWithOrThrow") fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` Returns the first entry having the smallest value according to the provided [comparator](min-with#kotlin.collections%24minWith(kotlin.collections.Map((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)))))/comparator). Exceptions ---------- `NoSuchElementException` - if the map is empty. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T> Array<out T>.minWith(     comparator: Comparator<in T> ): T? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun ByteArray.minWith(     comparator: Comparator<in Byte> ): Byte? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun ShortArray.minWith(     comparator: Comparator<in Short> ): Short? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun IntArray.minWith(     comparator: Comparator<in Int> ): Int? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun LongArray.minWith(     comparator: Comparator<in Long> ): Long? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun FloatArray.minWith(     comparator: Comparator<in Float> ): Float? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun DoubleArray.minWith(     comparator: Comparator<in Double> ): Double? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun BooleanArray.minWith(     comparator: Comparator<in Boolean> ): Boolean? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun CharArray.minWith(     comparator: Comparator<in Char> ): Char? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T> Iterable<T>.minWith(     comparator: Comparator<in T> ): T? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UIntArray.minWith(     comparator: Comparator<in UInt> ): UInt? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun ULongArray.minWith(     comparator: Comparator<in ULong> ): ULong? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UByteArray.minWith(     comparator: Comparator<in UByte> ): UByte? ``` **Deprecated:** Use minWithOrNull instead. ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UShortArray.minWith(     comparator: Comparator<in UShort> ): UShort? ``` **Deprecated:** Use minWithOrNull instead.
programming_docs
kotlin shuffled shuffled ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <shuffled> **Platform and version requirements:** JVM (1.2), JS (1.2) ``` fun <T> Iterable<T>.shuffled(): List<T> ``` Returns a new list with the elements of this list randomly shuffled. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` Returns a new list with the elements of this list randomly shuffled using the specified [random](shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. kotlin minOf minOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minOf](min-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Array<out T>.minOf(     selector: (T) -> Double ): Double ``` ``` inline fun ByteArray.minOf(     selector: (Byte) -> Double ): Double ``` ``` inline fun ShortArray.minOf(     selector: (Short) -> Double ): Double ``` ``` inline fun IntArray.minOf(selector: (Int) -> Double): Double ``` ``` inline fun LongArray.minOf(     selector: (Long) -> Double ): Double ``` ``` inline fun FloatArray.minOf(     selector: (Float) -> Double ): Double ``` ``` inline fun DoubleArray.minOf(     selector: (Double) -> Double ): Double ``` ``` inline fun BooleanArray.minOf(     selector: (Boolean) -> Double ): Double ``` ``` inline fun CharArray.minOf(     selector: (Char) -> Double ): Double ``` ``` inline fun <T> Array<out T>.minOf(     selector: (T) -> Float ): Float ``` ``` inline fun ByteArray.minOf(selector: (Byte) -> Float): Float ``` ``` inline fun ShortArray.minOf(     selector: (Short) -> Float ): Float ``` ``` inline fun IntArray.minOf(selector: (Int) -> Float): Float ``` ``` inline fun LongArray.minOf(selector: (Long) -> Float): Float ``` ``` inline fun FloatArray.minOf(     selector: (Float) -> Float ): Float ``` ``` inline fun DoubleArray.minOf(     selector: (Double) -> Float ): Float ``` ``` inline fun BooleanArray.minOf(     selector: (Boolean) -> Float ): Float ``` ``` inline fun CharArray.minOf(selector: (Char) -> Float): Float ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.minOf(     selector: (UInt) -> Double ): Double ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.minOf(     selector: (ULong) -> Double ): Double ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.minOf(     selector: (UByte) -> Double ): Double ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.minOf(     selector: (UShort) -> Double ): Double ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.minOf(     selector: (UInt) -> Float ): Float ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.minOf(     selector: (ULong) -> Float ): Float ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.minOf(     selector: (UByte) -> Float ): Float ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.minOf(     selector: (UShort) -> Float ): Float ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.Array((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. If any of values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.Array((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Array<out T>.minOf(     selector: (T) -> R ): R ``` ``` inline fun <R : Comparable<R>> ByteArray.minOf(     selector: (Byte) -> R ): R ``` ``` inline fun <R : Comparable<R>> ShortArray.minOf(     selector: (Short) -> R ): R ``` ``` inline fun <R : Comparable<R>> IntArray.minOf(     selector: (Int) -> R ): R ``` ``` inline fun <R : Comparable<R>> LongArray.minOf(     selector: (Long) -> R ): R ``` ``` inline fun <R : Comparable<R>> FloatArray.minOf(     selector: (Float) -> R ): R ``` ``` inline fun <R : Comparable<R>> DoubleArray.minOf(     selector: (Double) -> R ): R ``` ``` inline fun <R : Comparable<R>> BooleanArray.minOf(     selector: (Boolean) -> R ): R ``` ``` inline fun <R : Comparable<R>> CharArray.minOf(     selector: (Char) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.minOf(     selector: (UInt) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.minOf(     selector: (ULong) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.minOf(     selector: (UByte) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.minOf(     selector: (UShort) -> R ): R ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.Array((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.collections.minOf.R)))/selector) function applied to each element in the array. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Iterable<T>.minOf(     selector: (T) -> Double ): Double ``` ``` inline fun <T> Iterable<T>.minOf(     selector: (T) -> Float ): Float ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. If any of values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.collections.minOf.R)))/selector) function applied to each element in the collection. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` inline fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Float ): Float ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. If any of values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. Exceptions ---------- `NoSuchElementException` - if the map is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R : Comparable<R>> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> R ): R ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.collections.minOf.R)))/selector) function applied to each entry in the map. Exceptions ---------- `NoSuchElementException` - if the map is empty. kotlin mapKeysTo mapKeysTo ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapKeysTo](map-keys-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` Populates the given [destination](map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/destination) map with entries having the keys obtained by applying the [transform](map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/transform) function to each entry in this [Map](-map/index#kotlin.collections.Map) and the values of this map. In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite the value associated with the former one. kotlin binarySearchBy binarySearchBy ============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [binarySearchBy](binary-search-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     crossinline selector: (T) -> K? ): Int ``` Searches this list or its range for an element having the key returned by the specified [selector](binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. If the list contains multiple elements with the specified [key](binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key), there is no guarantee which one will be found. `null` value is considered to be less than any non-null value. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Box(val value: Int) val numbers = listOf(1, 3, 7, 10, 12) val boxes = numbers.map { Box(it) } println(boxes.binarySearchBy(10) { it.value }) // 3 //sampleEnd } ``` **Return** the index of the element with the specified [key](binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key), if it is contained in the list within the specified range; otherwise, the inverted insertion point `(-insertion point - 1)`. The insertion point is defined as the index at which the element should be inserted, so that the list (or the specified subrange of list) still remains sorted. kotlin toString toString ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0) ``` fun ByteArray.toString(charset: Charset): String ``` Converts the contents of this byte array to a string using the specified [charset](to-string#kotlin.collections%24toString(kotlin.ByteArray,%20java.nio.charset.Charset)/charset). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val charset = Charsets.UTF_8 val byteArray = "Hello".toByteArray(charset) println(byteArray.contentToString()) // [72, 101, 108, 108, 111] println(byteArray.toString(charset)) // Hello //sampleEnd } ``` kotlin max max === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <max> **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun Array<out Double>.max(): Double ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Array<out Double>.max(): Double? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun Array<out Float>.max(): Float ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Array<out Float>.max(): Float? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun FloatArray.max(): Float ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun FloatArray.max(): Float? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun DoubleArray.max(): Double ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun DoubleArray.max(): Double? ``` **Deprecated:** Use maxOrNull instead. Returns the largest element. If any of elements is `NaN` returns `NaN`. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun <T : Comparable<T>> Array<out T>.max(): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T : Comparable<T>> Array<out T>.max(): T? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun ByteArray.max(): Byte ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun ByteArray.max(): Byte? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun ShortArray.max(): Short ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun ShortArray.max(): Short? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun IntArray.max(): Int ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun IntArray.max(): Int? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun LongArray.max(): Long ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun LongArray.max(): Long? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun CharArray.max(): Char ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun CharArray.max(): Char? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow-U") @ExperimentalUnsignedTypes fun UIntArray.max(): UInt ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UIntArray.max(): UInt? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow-U") @ExperimentalUnsignedTypes fun ULongArray.max(): ULong ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun ULongArray.max(): ULong? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow-U") @ExperimentalUnsignedTypes fun UByteArray.max(): UByte ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UByteArray.max(): UByte? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow-U") @ExperimentalUnsignedTypes fun UShortArray.max(): UShort ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UShortArray.max(): UShort? ``` **Deprecated:** Use maxOrNull instead. Returns the largest element. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun Iterable<Double>.max(): Double ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Iterable<Double>.max(): Double? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun Iterable<Float>.max(): Float ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Iterable<Float>.max(): Float? ``` **Deprecated:** Use maxOrNull instead. Returns the largest element. If any of elements is `NaN` returns `NaN`. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun <T : Comparable<T>> Iterable<T>.max(): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T : Comparable<T>> Iterable<T>.max(): T? ``` **Deprecated:** Use maxOrNull instead. Returns the largest element. Exceptions ---------- `NoSuchElementException` - if the collection is empty. kotlin contentDeepToString contentDeepToString =================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [contentDeepToString](content-deep-to-string) **Platform and version requirements:** JS (1.1), Native (1.1) ``` fun <T> Array<out T>.contentDeepToString(): String ``` **Platform and version requirements:** JVM (1.1) ``` @JvmName("contentDeepToStringInline") fun <T> Array<out T>.contentDeepToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun <T> Array<out T>?.contentDeepToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentDeepToStringNullable") fun <T> Array<out T>?.contentDeepToString(): String ``` Returns a string representation of the contents of this array as if it is a [List](-list/index#kotlin.collections.List). Nested arrays are treated as lists too. If any of arrays contains itself on any nesting level that reference is rendered as `"[...]"` to prevent recursion. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val matrix = arrayOf( intArrayOf(3, 7, 9), intArrayOf(0, 1, 0), intArrayOf(2, 4, 8) ) println(matrix.contentDeepToString()) // [[3, 7, 9], [0, 1, 0], [2, 4, 8]] //sampleEnd } ```
programming_docs
kotlin lastIndex lastIndex ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [lastIndex](last-index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val <T> Array<out T>.lastIndex: Int ``` ``` val ByteArray.lastIndex: Int ``` ``` val ShortArray.lastIndex: Int ``` ``` val IntArray.lastIndex: Int ``` ``` val LongArray.lastIndex: Int ``` ``` val FloatArray.lastIndex: Int ``` ``` val DoubleArray.lastIndex: Int ``` ``` val BooleanArray.lastIndex: Int ``` ``` val CharArray.lastIndex: Int ``` ``` @ExperimentalUnsignedTypes inline val UIntArray.lastIndex: Int ``` ``` @ExperimentalUnsignedTypes inline val ULongArray.lastIndex: Int ``` ``` @ExperimentalUnsignedTypes inline val UByteArray.lastIndex: Int ``` ``` @ExperimentalUnsignedTypes inline val UShortArray.lastIndex: Int ``` Returns the last valid index for the array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val <T> List<T>.lastIndex: Int ``` Returns the index of the last item in the list or -1 if the list is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart println(emptyList<Any>().lastIndex) // -1 val list = listOf("a", "x", "y") println(list.lastIndex) // 2 println(list[list.lastIndex]) // y //sampleEnd } ``` kotlin indexOfFirst indexOfFirst ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [indexOfFirst](index-of-first) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` ``` inline fun ByteArray.indexOfFirst(     predicate: (Byte) -> Boolean ): Int ``` ``` inline fun ShortArray.indexOfFirst(     predicate: (Short) -> Boolean ): Int ``` ``` inline fun IntArray.indexOfFirst(     predicate: (Int) -> Boolean ): Int ``` ``` inline fun LongArray.indexOfFirst(     predicate: (Long) -> Boolean ): Int ``` ``` inline fun FloatArray.indexOfFirst(     predicate: (Float) -> Boolean ): Int ``` ``` inline fun DoubleArray.indexOfFirst(     predicate: (Double) -> Boolean ): Int ``` ``` inline fun BooleanArray.indexOfFirst(     predicate: (Boolean) -> Boolean ): Int ``` ``` inline fun CharArray.indexOfFirst(     predicate: (Char) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.indexOfFirst(     predicate: (UInt) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.indexOfFirst(     predicate: (ULong) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.indexOfFirst(     predicate: (UByte) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.indexOfFirst(     predicate: (UShort) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](index-of-first#kotlin.collections%24indexOfFirst(kotlin.Array((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> List<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. kotlin groupingBy groupingBy ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [groupingBy](grouping-by) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K> Array<out T>.groupingBy(     crossinline keySelector: (T) -> K ): Grouping<T, K> ``` Creates a [Grouping](-grouping/index) source from an array to be used later with one of group-and-fold operations using the specified [keySelector](grouping-by#kotlin.collections%24groupingBy(kotlin.Array((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun main(args: Array<String>) { //sampleStart val words = "one two three four five six seven eight nine ten".split(' ') val frequenciesByFirstChar = words.groupingBy { it.first() }.eachCount() println("Counting first letters:") println(frequenciesByFirstChar) // {o=1, t=3, f=2, s=2, e=1, n=1} val moreWords = "eleven twelve".split(' ') val moreFrequencies = moreWords.groupingBy { it.first() }.eachCountTo(frequenciesByFirstChar.toMutableMap()) println(moreFrequencies) // {o=1, t=4, f=2, s=2, e=2, n=1} //sampleEnd } ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K> Iterable<T>.groupingBy(     crossinline keySelector: (T) -> K ): Grouping<T, K> ``` Creates a [Grouping](-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun main(args: Array<String>) { //sampleStart val words = "one two three four five six seven eight nine ten".split(' ') val frequenciesByFirstChar = words.groupingBy { it.first() }.eachCount() println("Counting first letters:") println(frequenciesByFirstChar) // {o=1, t=3, f=2, s=2, e=1, n=1} val moreWords = "eleven twelve".split(' ') val moreFrequencies = moreWords.groupingBy { it.first() }.eachCountTo(frequenciesByFirstChar.toMutableMap()) println(moreFrequencies) // {o=1, t=4, f=2, s=2, e=2, n=1} //sampleEnd } ``` kotlin emptyMap emptyMap ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [emptyMap](empty-map) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> emptyMap(): Map<K, V> ``` Returns an empty read-only map of specified type. The returned map is serializable (JVM). ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = emptyMap<String, Int>() println("map.isEmpty() is ${map.isEmpty()}") // true val anotherMap = mapOf<String, Int>() // Empty maps are equal println("map == anotherMap is ${map == anotherMap}") // true //sampleEnd } ``` kotlin flatMapTo flatMapTo ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [flatMapTo](flat-map-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` inline fun <R, C : MutableCollection<in R>> ByteArray.flatMapTo(     destination: C,     transform: (Byte) -> Iterable<R> ): C ``` ``` inline fun <R, C : MutableCollection<in R>> ShortArray.flatMapTo(     destination: C,     transform: (Short) -> Iterable<R> ): C ``` ``` inline fun <R, C : MutableCollection<in R>> IntArray.flatMapTo(     destination: C,     transform: (Int) -> Iterable<R> ): C ``` ``` inline fun <R, C : MutableCollection<in R>> LongArray.flatMapTo(     destination: C,     transform: (Long) -> Iterable<R> ): C ``` ``` inline fun <R, C : MutableCollection<in R>> FloatArray.flatMapTo(     destination: C,     transform: (Float) -> Iterable<R> ): C ``` ``` inline fun <R, C : MutableCollection<in R>> DoubleArray.flatMapTo(     destination: C,     transform: (Double) -> Iterable<R> ): C ``` ``` inline fun <R, C : MutableCollection<in R>> BooleanArray.flatMapTo(     destination: C,     transform: (Boolean) -> Iterable<R> ): C ``` ``` inline fun <R, C : MutableCollection<in R>> CharArray.flatMapTo(     destination: C,     transform: (Char) -> Iterable<R> ): C ``` ``` @JvmName("flatMapSequenceTo") inline fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UIntArray.flatMapTo(     destination: C,     transform: (UInt) -> Iterable<R> ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> ULongArray.flatMapTo(     destination: C,     transform: (ULong) -> Iterable<R> ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UByteArray.flatMapTo(     destination: C,     transform: (UByte) -> Iterable<R> ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UShortArray.flatMapTo(     destination: C,     transform: (UShort) -> Iterable<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-to#kotlin.collections%24flatMapTo(kotlin.Array((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original array, to the given [destination](flat-map-to#kotlin.collections%24flatMapTo(kotlin.Array((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` @JvmName("flatMapSequenceTo") inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Iterable<R> ): C ``` ``` @JvmName("flatMapSequenceTo") inline fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Sequence<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each entry of original map, to the given [destination](flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). kotlin mutableListOf mutableListOf ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mutableListOf](mutable-list-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> mutableListOf(): MutableList<T> ``` Returns an empty new [MutableList](-mutable-list/index#kotlin.collections.MutableList). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = mutableListOf<Int>() println("list.isEmpty() is ${list.isEmpty()}") // true list.addAll(listOf(1, 2, 3)) println(list) // [1, 2, 3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> mutableListOf(vararg elements: T): MutableList<T> ``` Returns a new [MutableList](-mutable-list/index#kotlin.collections.MutableList) with the given elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = mutableListOf(1, 2, 3) println(list) // [1, 2, 3] list += listOf(4, 5) println(list) // [1, 2, 3, 4, 5] //sampleEnd } ``` kotlin linkedSetOf linkedSetOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [linkedSetOf](linked-set-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> linkedSetOf(): LinkedHashSet<T> ``` Returns an empty new [LinkedHashSet](-linked-hash-set/index#kotlin.collections.LinkedHashSet). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val set: LinkedHashSet<Int> = linkedSetOf<Int>() set.add(1) set.add(3) set.add(2) println(set) // [1, 3, 2] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> linkedSetOf(vararg elements: T): LinkedHashSet<T> ``` Returns a new [LinkedHashSet](-linked-hash-set/index#kotlin.collections.LinkedHashSet) with the given elements. Elements of the set are iterated in the order they were specified. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val set: LinkedHashSet<Int> = linkedSetOf(1, 3, 2) println(set) // [1, 3, 2] set.remove(3) set += listOf(5, 4) println(set) // [1, 2, 5, 4] //sampleEnd } ``` kotlin toSet toSet ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toSet](to-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.toSet(): Set<T> ``` ``` fun ByteArray.toSet(): Set<Byte> ``` ``` fun ShortArray.toSet(): Set<Short> ``` ``` fun IntArray.toSet(): Set<Int> ``` ``` fun LongArray.toSet(): Set<Long> ``` ``` fun FloatArray.toSet(): Set<Float> ``` ``` fun DoubleArray.toSet(): Set<Double> ``` ``` fun BooleanArray.toSet(): Set<Boolean> ``` ``` fun CharArray.toSet(): Set<Char> ``` Returns a [Set](-set/index#kotlin.collections.Set) of all elements. The returned set preserves the element iteration order of the original array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.toSet(): Set<T> ``` Returns a [Set](-set/index#kotlin.collections.Set) of all elements. The returned set preserves the element iteration order of the original collection. kotlin minByOrNull minByOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minByOrNull](min-by-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Array<out T>.minByOrNull(     selector: (T) -> R ): T? ``` ``` inline fun <R : Comparable<R>> ByteArray.minByOrNull(     selector: (Byte) -> R ): Byte? ``` ``` inline fun <R : Comparable<R>> ShortArray.minByOrNull(     selector: (Short) -> R ): Short? ``` ``` inline fun <R : Comparable<R>> IntArray.minByOrNull(     selector: (Int) -> R ): Int? ``` ``` inline fun <R : Comparable<R>> LongArray.minByOrNull(     selector: (Long) -> R ): Long? ``` ``` inline fun <R : Comparable<R>> FloatArray.minByOrNull(     selector: (Float) -> R ): Float? ``` ``` inline fun <R : Comparable<R>> DoubleArray.minByOrNull(     selector: (Double) -> R ): Double? ``` ``` inline fun <R : Comparable<R>> BooleanArray.minByOrNull(     selector: (Boolean) -> R ): Boolean? ``` ``` inline fun <R : Comparable<R>> CharArray.minByOrNull(     selector: (Char) -> R ): Char? ``` ``` inline fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.minByOrNull(     selector: (UInt) -> R ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.minByOrNull(     selector: (ULong) -> R ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.minByOrNull(     selector: (UByte) -> R ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.minByOrNull(     selector: (UShort) -> R ): UShort? ``` Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("abcd", "abc", "ab", "abcde") val shortestString = list.minByOrNull { it.length } println(shortestString) // ab val emptyList = emptyList<String>() val emptyMin = emptyList.minByOrNull { it.length } println(emptyMin) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R : Comparable<R>> Map<out K, V>.minByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("abcd", "abc", "ab", "abcde") val shortestString = list.minByOrNull { it.length } println(shortestString) // ab val emptyList = emptyList<String>() val emptyMin = emptyList.minByOrNull { it.length } println(emptyMin) // null //sampleEnd } ``` kotlin toIntArray toIntArray ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toIntArray](to-int-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Array<out Int>.toIntArray(): IntArray ``` Returns an array of Int containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Collection<Int>.toIntArray(): IntArray ``` Returns an array of Int containing all of the elements of this collection. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.toIntArray(): IntArray ``` Returns an array of type [IntArray](../kotlin/-int-array/index#kotlin.IntArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. kotlin minWithOrNull minWithOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minWithOrNull](min-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Array<out T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` ``` fun ByteArray.minWithOrNull(     comparator: Comparator<in Byte> ): Byte? ``` ``` fun ShortArray.minWithOrNull(     comparator: Comparator<in Short> ): Short? ``` ``` fun IntArray.minWithOrNull(     comparator: Comparator<in Int> ): Int? ``` ``` fun LongArray.minWithOrNull(     comparator: Comparator<in Long> ): Long? ``` ``` fun FloatArray.minWithOrNull(     comparator: Comparator<in Float> ): Float? ``` ``` fun DoubleArray.minWithOrNull(     comparator: Comparator<in Double> ): Double? ``` ``` fun BooleanArray.minWithOrNull(     comparator: Comparator<in Boolean> ): Boolean? ``` ``` fun CharArray.minWithOrNull(     comparator: Comparator<in Char> ): Char? ``` ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.minWithOrNull(     comparator: Comparator<in UInt> ): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.minWithOrNull(     comparator: Comparator<in ULong> ): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.minWithOrNull(     comparator: Comparator<in UByte> ): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.minWithOrNull(     comparator: Comparator<in UShort> ): UShort? ``` Returns the first element having the smallest value according to the provided [comparator](min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.Array((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <K, V> Map<out K, V>.minWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` Returns the first entry having the smallest value according to the provided [comparator](min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Map((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)))))/comparator) or `null` if there are no entries.
programming_docs
kotlin removeLast removeLast ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [removeLast](remove-last) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> MutableList<T>.removeLast(): T ``` Removes the last element from this mutable list and returns that removed element, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. kotlin min min === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <min> **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun Array<out Double>.min(): Double ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Array<out Double>.min(): Double? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun Array<out Float>.min(): Float ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Array<out Float>.min(): Float? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun FloatArray.min(): Float ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun FloatArray.min(): Float? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun DoubleArray.min(): Double ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun DoubleArray.min(): Double? ``` **Deprecated:** Use minOrNull instead. Returns the smallest element. If any of elements is `NaN` returns `NaN`. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun <T : Comparable<T>> Array<out T>.min(): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T : Comparable<T>> Array<out T>.min(): T? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun ByteArray.min(): Byte ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun ByteArray.min(): Byte? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun ShortArray.min(): Short ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun ShortArray.min(): Short? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun IntArray.min(): Int ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun IntArray.min(): Int? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun LongArray.min(): Long ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun LongArray.min(): Long? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun CharArray.min(): Char ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun CharArray.min(): Char? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow-U") @ExperimentalUnsignedTypes fun UIntArray.min(): UInt ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UIntArray.min(): UInt? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow-U") @ExperimentalUnsignedTypes fun ULongArray.min(): ULong ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun ULongArray.min(): ULong? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow-U") @ExperimentalUnsignedTypes fun UByteArray.min(): UByte ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UByteArray.min(): UByte? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow-U") @ExperimentalUnsignedTypes fun UShortArray.min(): UShort ``` **Platform and version requirements:** JVM (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes fun UShortArray.min(): UShort? ``` **Deprecated:** Use minOrNull instead. Returns the smallest element. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun Iterable<Double>.min(): Double ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Iterable<Double>.min(): Double? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun Iterable<Float>.min(): Float ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Iterable<Float>.min(): Float? ``` **Deprecated:** Use minOrNull instead. Returns the smallest element. If any of elements is `NaN` returns `NaN`. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun <T : Comparable<T>> Iterable<T>.min(): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T : Comparable<T>> Iterable<T>.min(): T? ``` **Deprecated:** Use minOrNull instead. Returns the smallest element. Exceptions ---------- `NoSuchElementException` - if the collection is empty. kotlin getOrPut getOrPut ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [getOrPut](get-or-put) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> MutableMap<K, V>.getOrPut(     key: K,     defaultValue: () -> V ): V ``` Returns the value for the given [key](get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/key) if the value is present and not `null`. Otherwise, calls the [defaultValue](get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/defaultValue) function, puts its result into the map under the given key and returns the call result. Note that the operation is not guaranteed to be atomic if the map is being modified concurrently. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map = mutableMapOf<String, Int?>() println(map.getOrPut("x") { 2 }) // 2 // subsequent calls to getOrPut do not evaluate the default value // since the first getOrPut has already stored value 2 in the map println(map.getOrPut("x") { 3 }) // 2 // however null value mapped to a key is treated the same as the missing value println(map.getOrPut("y") { null }) // null // so in that case the default value is evaluated println(map.getOrPut("y") { 42 }) // 42 //sampleEnd } ``` kotlin component2 component2 ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <component2> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Array<out T>.component2(): T ``` ``` operator fun ByteArray.component2(): Byte ``` ``` operator fun ShortArray.component2(): Short ``` ``` operator fun IntArray.component2(): Int ``` ``` operator fun LongArray.component2(): Long ``` ``` operator fun FloatArray.component2(): Float ``` ``` operator fun DoubleArray.component2(): Double ``` ``` operator fun BooleanArray.component2(): Boolean ``` ``` operator fun CharArray.component2(): Char ``` ``` @ExperimentalUnsignedTypes operator fun UIntArray.component2(): UInt ``` ``` @ExperimentalUnsignedTypes operator fun ULongArray.component2(): ULong ``` ``` @ExperimentalUnsignedTypes operator fun UByteArray.component2(): UByte ``` ``` @ExperimentalUnsignedTypes operator fun UShortArray.component2(): UShort ``` Returns 2nd *element* from the array. If the size of this array is less than 2, throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) except in Kotlin/JS where the behavior is unspecified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> List<T>.component2(): T ``` Returns 2nd *element* from the list. Throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the size of this list is less than 2. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Entry<K, V>.component2(): V ``` Returns the value component of the map entry. This method allows to use destructuring declarations when working with maps, for example: ``` for ((key, value) in map) { // do something with the key and the value } ``` kotlin contentDeepEquals contentDeepEquals ================= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [contentDeepEquals](content-deep-equals) **Platform and version requirements:** JS (1.1), Native (1.1) ``` infix fun <T> Array<out T>.contentDeepEquals(     other: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.1) ``` @JvmName("contentDeepEqualsInline") infix fun <T> Array<out T>.contentDeepEquals(     other: Array<out T> ): Boolean ``` Returns `true` if the two specified arrays are *deeply* equal to one another, i.e. contain the same number of the same elements in the same order. If two corresponding elements are nested arrays, they are also compared deeply. If any of arrays contains itself on any nesting level the behavior is undefined. The elements of other types are compared for equality with the [equals](../kotlin/-any/equals#kotlin.Any%24equals(kotlin.Any?)) function. For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. **Platform and version requirements:** JS (1.4), Native (1.4) ``` infix fun <T> Array<out T>?.contentDeepEquals(     other: Array<out T>? ): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentDeepEqualsNullable") infix fun <T> Array<out T>?.contentDeepEquals(     other: Array<out T>? ): Boolean ``` Returns `true` if the two specified arrays are *deeply* equal to one another, i.e. contain the same number of the same elements in the same order. The specified arrays are also considered deeply equal if both are `null`. If two corresponding elements are nested arrays, they are also compared deeply. If any of arrays contains itself on any nesting level the behavior is undefined. The elements of other types are compared for equality with the [equals](../kotlin/-any/equals#kotlin.Any%24equals(kotlin.Any?)) function. For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. kotlin sortedArrayDescending sortedArrayDescending ===================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedArrayDescending](sorted-array-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> Array<T>.sortedArrayDescending(): Array<T> ``` Returns an array with all elements of this array sorted descending according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.sortedArrayDescending(): ByteArray ``` ``` fun ShortArray.sortedArrayDescending(): ShortArray ``` ``` fun IntArray.sortedArrayDescending(): IntArray ``` ``` fun LongArray.sortedArrayDescending(): LongArray ``` ``` fun FloatArray.sortedArrayDescending(): FloatArray ``` ``` fun DoubleArray.sortedArrayDescending(): DoubleArray ``` ``` fun CharArray.sortedArrayDescending(): CharArray ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sortedArrayDescending(): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sortedArrayDescending(): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sortedArrayDescending(): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sortedArrayDescending(): UShortArray ``` Returns an array with all elements of this array sorted descending according to their natural sort order. kotlin associateBy associateBy =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [associateBy](associate-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> Array<out T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` ``` inline fun <K> ByteArray.associateBy(     keySelector: (Byte) -> K ): Map<K, Byte> ``` ``` inline fun <K> ShortArray.associateBy(     keySelector: (Short) -> K ): Map<K, Short> ``` ``` inline fun <K> IntArray.associateBy(     keySelector: (Int) -> K ): Map<K, Int> ``` ``` inline fun <K> LongArray.associateBy(     keySelector: (Long) -> K ): Map<K, Long> ``` ``` inline fun <K> FloatArray.associateBy(     keySelector: (Float) -> K ): Map<K, Float> ``` ``` inline fun <K> DoubleArray.associateBy(     keySelector: (Double) -> K ): Map<K, Double> ``` ``` inline fun <K> BooleanArray.associateBy(     keySelector: (Boolean) -> K ): Map<K, Boolean> ``` ``` inline fun <K> CharArray.associateBy(     keySelector: (Char) -> K ): Map<K, Char> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing the elements from the given array indexed by the key returned from [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.Array((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. If any two elements would have the same key returned by [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.Array((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) the last one gets added to the map. The returned map preserves the entry iteration order of the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val charCodes = intArrayOf(72, 69, 76, 76, 79) val byChar = charCodes.associateBy { Char(it) } // L=76 only occurs once because only the last pair with the same key gets added println(byChar) // {H=72, E=69, L=76, O=79} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Array<out T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` ``` inline fun <K, V> ByteArray.associateBy(     keySelector: (Byte) -> K,     valueTransform: (Byte) -> V ): Map<K, V> ``` ``` inline fun <K, V> ShortArray.associateBy(     keySelector: (Short) -> K,     valueTransform: (Short) -> V ): Map<K, V> ``` ``` inline fun <K, V> IntArray.associateBy(     keySelector: (Int) -> K,     valueTransform: (Int) -> V ): Map<K, V> ``` ``` inline fun <K, V> LongArray.associateBy(     keySelector: (Long) -> K,     valueTransform: (Long) -> V ): Map<K, V> ``` ``` inline fun <K, V> FloatArray.associateBy(     keySelector: (Float) -> K,     valueTransform: (Float) -> V ): Map<K, V> ``` ``` inline fun <K, V> DoubleArray.associateBy(     keySelector: (Double) -> K,     valueTransform: (Double) -> V ): Map<K, V> ``` ``` inline fun <K, V> BooleanArray.associateBy(     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> V ): Map<K, V> ``` ``` inline fun <K, V> CharArray.associateBy(     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): Map<K, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](associate-by#kotlin.collections%24associateBy(kotlin.Array((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.Array((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. If any two elements would have the same key returned by [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.Array((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) the last one gets added to the map. The returned map preserves the entry iteration order of the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val charCodes = intArrayOf(65, 65, 66, 67, 68, 69) val byUpperCase = charCodes.associateBy({ Char(it) }, { Char(it + 32) }) // A=a only occurs once because only the last pair with the same key gets added println(byUpperCase) // {A=a, B=b, C=c, D=d, E=e} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. If any two elements would have the same key returned by [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) the last one gets added to the map. The returned map preserves the entry iteration order of the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = scientists.associateBy { it.lastName } // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace Hopper, Bernoulli=Johann Bernoulli} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. If any two elements would have the same key returned by [keySelector](associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) the last one gets added to the map. The returned map preserves the entry iteration order of the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = scientists.associateBy({ it.lastName }, { it.firstName }) // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace, Bernoulli=Johann} //sampleEnd } ```
programming_docs
kotlin filterNotTo filterNotTo =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterNotTo](filter-not-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, C : MutableCollection<in T>> Array<out T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Byte>> ByteArray.filterNotTo(     destination: C,     predicate: (Byte) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Short>> ShortArray.filterNotTo(     destination: C,     predicate: (Short) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Int>> IntArray.filterNotTo(     destination: C,     predicate: (Int) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Long>> LongArray.filterNotTo(     destination: C,     predicate: (Long) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Float>> FloatArray.filterNotTo(     destination: C,     predicate: (Float) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Double>> DoubleArray.filterNotTo(     destination: C,     predicate: (Double) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterNotTo(     destination: C,     predicate: (Boolean) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Char>> CharArray.filterNotTo(     destination: C,     predicate: (Char) -> Boolean ): C ``` ``` inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UInt>> UIntArray.filterNotTo(     destination: C,     predicate: (UInt) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in ULong>> ULongArray.filterNotTo(     destination: C,     predicate: (ULong) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UByte>> UByteArray.filterNotTo(     destination: C,     predicate: (UByte) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UShort>> UShortArray.filterNotTo(     destination: C,     predicate: (UShort) -> Boolean ): C ``` Appends all elements not matching the given [predicate](filter-not-to#kotlin.collections%24filterNotTo(kotlin.Array((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-not-to#kotlin.collections%24filterNotTo(kotlin.Array((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = mutableListOf<Int>() val notMultiplesOf3 = mutableListOf<Int>() println(evenNumbers) // [] numbers.filterTo(evenNumbers) { it % 2 == 0 } numbers.filterNotTo(notMultiplesOf3) { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` Appends all entries not matching the given [predicate](filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/predicate) into the given [destination](filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/destination). ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val originalMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3) val destinationMap = mutableMapOf("key40" to 40, "key50" to 50) val filteredMap = originalMap.filterNotTo(destinationMap) { it.value < 3 } //destination map instance has been updated println("destinationMap === filteredMap is ${destinationMap === filteredMap}") // true println(destinationMap) // {key40=40, key50=50, key3=3} // original map has not changed println(originalMap) // {key1=1, key2=2, key3=3} val anotherDestinationMap = mutableMapOf("key40" to 40, "key50" to 50) val matchAllPredicate: ((Map.Entry<String, Int>)) -> Boolean = { it.value > 0 } val filteredMapWithEverythingMatched = originalMap.filterNotTo(anotherDestinationMap, matchAllPredicate) println(filteredMapWithEverythingMatched) // {key40=40, key50=50} //sampleEnd } ``` **Return** the destination map. kotlin reversed reversed ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <reversed> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.reversed(): List<T> ``` ``` fun ByteArray.reversed(): List<Byte> ``` ``` fun ShortArray.reversed(): List<Short> ``` ``` fun IntArray.reversed(): List<Int> ``` ``` fun LongArray.reversed(): List<Long> ``` ``` fun FloatArray.reversed(): List<Float> ``` ``` fun DoubleArray.reversed(): List<Double> ``` ``` fun BooleanArray.reversed(): List<Boolean> ``` ``` fun CharArray.reversed(): List<Char> ``` ``` fun <T> Iterable<T>.reversed(): List<T> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.reversed(): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.reversed(): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.reversed(): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.reversed(): List<UShort> ``` Returns a list with elements in reversed order. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [removeAll](remove-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all of this collection's elements that are also contained in the specified collection. Allows to overcome type-safety restriction of `removeAll` that requires to pass a collection of type `Collection<E>`. **Return** `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` Removes all elements from this [MutableIterable](-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). **Return** `true` if any element was removed from this collection, or `false` when no elements were removed and collection was not modified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableList<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` Removes all elements from this [MutableList](-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableList((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). **Return** `true` if any element was removed from this collection, or `false` when no elements were removed and collection was not modified. kotlin toUByteArray toUByteArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toUByteArray](to-u-byte-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun Array<out UByte>.toUByteArray(): UByteArray ``` Returns an array of UByte containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ByteArray.toUByteArray(): UByteArray ``` Returns an array of type [UByteArray](../kotlin/-u-byte-array/index), which is a copy of this array where each element is an unsigned reinterpretation of the corresponding element of this array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun Collection<UByte>.toUByteArray(): UByteArray ``` Returns an array of UByte containing all of the elements of this collection. kotlin emptyList emptyList ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [emptyList](empty-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> emptyList(): List<T> ``` Returns an empty read-only list. The returned list is serializable (JVM). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf<String>() println("list.isEmpty() is ${list.isEmpty()}") // true // another way to create an empty list, // type parameter is inferred from the expected type val other: List<Int> = emptyList() // Empty lists are equal println("list == other is ${list == other}") // true println(list) // [] // list[0] // will fail //sampleEnd } ``` kotlin flatMapIndexedTo flatMapIndexedTo ================ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [flatMapIndexedTo](flat-map-indexed-to) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("flatMapIndexedIterableTo") inline fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedIterableTo") inline fun <R, C : MutableCollection<in R>> ByteArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Byte) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedIterableTo") inline fun <R, C : MutableCollection<in R>> ShortArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Short) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedIterableTo") inline fun <R, C : MutableCollection<in R>> IntArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Int) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedIterableTo") inline fun <R, C : MutableCollection<in R>> LongArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Long) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedIterableTo") inline fun <R, C : MutableCollection<in R>> FloatArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Float) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedIterableTo") inline fun <R, C : MutableCollection<in R>> DoubleArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Double) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedIterableTo") inline fun <R, C : MutableCollection<in R>> BooleanArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Boolean) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedIterableTo") inline fun <R, C : MutableCollection<in R>> CharArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Char) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedSequenceTo") inline fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UIntArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, UInt) -> Iterable<R> ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> ULongArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, ULong) -> Iterable<R> ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UByteArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, UByte) -> Iterable<R> ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UShortArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, UShort) -> Iterable<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.Array((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original array, to the given [destination](flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.Array((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("flatMapIndexedIterableTo") inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedSequenceTo") inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). kotlin minOfWithOrNull minOfWithOrNull =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minOfWithOrNull](min-of-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Array<out T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` ``` inline fun <R> ByteArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Byte) -> R ): R? ``` ``` inline fun <R> ShortArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Short) -> R ): R? ``` ``` inline fun <R> IntArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Int) -> R ): R? ``` ``` inline fun <R> LongArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Long) -> R ): R? ``` ``` inline fun <R> FloatArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Float) -> R ): R? ``` ``` inline fun <R> DoubleArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Double) -> R ): R? ``` ``` inline fun <R> BooleanArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R? ``` ``` inline fun <R> CharArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UInt) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UByte) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UShort) -> R ): R? ``` Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.Array((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.Array((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R> Map<out K, V>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries.
programming_docs
kotlin toDoubleArray toDoubleArray ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toDoubleArray](to-double-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Array<out Double>.toDoubleArray(): DoubleArray ``` Returns an array of Double containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` Returns an array of Double containing all of the elements of this collection. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` Checks if all elements in the specified collection are contained in this collection. Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val collection = mutableListOf('a', 'b') val test = listOf('a', 'b', 'c') println("collection.containsAll(test) is ${collection.containsAll(test)}") // false collection.add('c') println("collection.containsAll(test) is ${collection.containsAll(test)}") // true //sampleEnd } ``` kotlin buildMap buildMap ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [buildMap](build-map) **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` inline fun <K, V> buildMap(     builderAction: MutableMap<K, V>.() -> Unit ): Map<K, V> ``` Builds a new read-only [Map](-map/index#kotlin.collections.Map) by populating a [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) using the given [builderAction](build-map#kotlin.collections%24buildMap(kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/builderAction) and returning a read-only map with the same key-value pairs. The map passed as a receiver to the [builderAction](build-map#kotlin.collections%24buildMap(kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/builderAction) is valid only inside that function. Using it outside of the function produces an unspecified behavior. Entries of the map are iterated in the order they were added by the [builderAction](build-map#kotlin.collections%24buildMap(kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/builderAction). The returned map is serializable (JVM). ``` fun main(args: Array<String>) { //sampleStart val x = mapOf('b' to 2, 'c' to 3) val y = buildMap<Char, Int>(x.size + 2) { put('a', 1) put('c', 0) putAll(x) put('d', 4) } println(y) // {a=1, c=3, b=2, d=4} //sampleEnd } ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` inline fun <K, V> buildMap(     capacity: Int,     builderAction: MutableMap<K, V>.() -> Unit ): Map<K, V> ``` Builds a new read-only [Map](-map/index#kotlin.collections.Map) by populating a [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) using the given [builderAction](build-map#kotlin.collections%24buildMap(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/builderAction) and returning a read-only map with the same key-value pairs. The map passed as a receiver to the [builderAction](build-map#kotlin.collections%24buildMap(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/builderAction) is valid only inside that function. Using it outside of the function produces an unspecified behavior. [capacity](build-map#kotlin.collections%24buildMap(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/capacity) is used to hint the expected number of pairs added in the [builderAction](build-map#kotlin.collections%24buildMap(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/builderAction). Entries of the map are iterated in the order they were added by the [builderAction](build-map#kotlin.collections%24buildMap(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/builderAction). The returned map is serializable (JVM). ``` fun main(args: Array<String>) { //sampleStart val x = mapOf('b' to 2, 'c' to 3) val y = buildMap<Char, Int>(x.size + 2) { put('a', 1) put('c', 0) putAll(x) put('d', 4) } println(y) // {a=1, c=3, b=2, d=4} //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if the given [capacity](build-map#kotlin.collections%24buildMap(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableMap((kotlin.collections.buildMap.K,%20kotlin.collections.buildMap.V)),%20kotlin.Unit)))/capacity) is negative. kotlin partition partition ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <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](partition#kotlin.collections%24partition(kotlin.Array((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](partition#kotlin.collections%24partition(kotlin.Array((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = intArrayOf(1, 2, 3, 4, 5) val (even, odd) = array.partition { it % 2 == 0 } println(even) // [2, 4] println(odd) // [1, 3, 5] //sampleEnd } ``` **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](partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun main(args: Array<String>) { //sampleStart data class Person(val name: String, val age: Int) { override fun toString(): String { return "$name - $age" } } val list = listOf(Person("Tom", 18), Person("Andy", 32), Person("Sarah", 22)) val result = list.partition { it.age < 30 } println(result) // ([Tom - 18, Sarah - 22], [Andy - 32]) //sampleEnd } ``` kotlin toMutableMap toMutableMap ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toMutableMap](to-mutable-map) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> ``` Returns a new mutable map containing all key-value pairs from the original map. The returned map preserves the entry iteration order of the original map. kotlin onEachIndexed onEachIndexed ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [onEachIndexed](on-each-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Array<out T>.onEachIndexed(     action: (index: Int, T) -> Unit ): Array<out T> ``` ``` inline fun ByteArray.onEachIndexed(     action: (index: Int, Byte) -> Unit ): ByteArray ``` ``` inline fun ShortArray.onEachIndexed(     action: (index: Int, Short) -> Unit ): ShortArray ``` ``` inline fun IntArray.onEachIndexed(     action: (index: Int, Int) -> Unit ): IntArray ``` ``` inline fun LongArray.onEachIndexed(     action: (index: Int, Long) -> Unit ): LongArray ``` ``` inline fun FloatArray.onEachIndexed(     action: (index: Int, Float) -> Unit ): FloatArray ``` ``` inline fun DoubleArray.onEachIndexed(     action: (index: Int, Double) -> Unit ): DoubleArray ``` ``` inline fun BooleanArray.onEachIndexed(     action: (index: Int, Boolean) -> Unit ): BooleanArray ``` ``` inline fun CharArray.onEachIndexed(     action: (index: Int, Char) -> Unit ): CharArray ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.onEachIndexed(     action: (index: Int, UInt) -> Unit ): UIntArray ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.onEachIndexed(     action: (index: Int, ULong) -> Unit ): ULongArray ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.onEachIndexed(     action: (index: Int, UByte) -> Unit ): UByteArray ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.onEachIndexed(     action: (index: Int, UShort) -> Unit ): UShortArray ``` Performs the given [action](on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.Array((kotlin.collections.onEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. Parameters ---------- `action` - function that takes the index of an element and the element itself and performs the action on the element. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` Performs the given [action](on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. Parameters ---------- `action` - function that takes the index of an element and the element itself and performs the action on the element. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, M : Map<out K, V>> M.onEachIndexed(     action: (index: Int, Entry<K, V>) -> Unit ): M ``` Performs the given [action](on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.M,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.Map.Entry((kotlin.collections.onEachIndexed.K,%20kotlin.collections.onEachIndexed.V)),%20kotlin.Unit)))/action) on each entry, providing sequential index with the entry, and returns the map itself afterwards. Parameters ---------- `action` - function that takes the index of an entry and the entry itself and performs the action on the entry. kotlin aggregateTo aggregateTo =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [aggregateTo](aggregate-to) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.aggregateTo(     destination: M,     operation: (key: K, accumulator: R?, element: T, first: Boolean) -> R ): M ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](aggregate-to#kotlin.collections%24aggregateTo(kotlin.collections.Grouping((kotlin.collections.aggregateTo.T,%20kotlin.collections.aggregateTo.K)),%20kotlin.collections.aggregateTo.M,%20kotlin.Function4((kotlin.collections.aggregateTo.K,%20kotlin.collections.aggregateTo.R?,%20kotlin.collections.aggregateTo.T,%20kotlin.Boolean,%20kotlin.collections.aggregateTo.R)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](aggregate-to#kotlin.collections%24aggregateTo(kotlin.collections.Grouping((kotlin.collections.aggregateTo.T,%20kotlin.collections.aggregateTo.K)),%20kotlin.collections.aggregateTo.M,%20kotlin.Function4((kotlin.collections.aggregateTo.K,%20kotlin.collections.aggregateTo.R?,%20kotlin.collections.aggregateTo.T,%20kotlin.Boolean,%20kotlin.collections.aggregateTo.R)))/destination) map. The key for each element is provided by the [Grouping.keyOf](-grouping/key-of) function. ``` fun main(args: Array<String>) { //sampleStart val numbers = listOf(3, 4, 5, 6, 7, 8, 9) val aggregated = numbers.groupingBy { it % 3 }.aggregateTo(mutableMapOf()) { key, accumulator: StringBuilder?, element, first -> if (first) // first element StringBuilder().append(key).append(":").append(element) else accumulator!!.append("-").append(element) } println(aggregated.values) // [0:3-6-9, 1:4-7, 2:5-8] // aggregated is a mutable map aggregated.clear() //sampleEnd } ``` Parameters ---------- `operation` - a function that is invoked on each element with the following parameters: * `key`: the key of the group this element belongs to; * `accumulator`: the current value of the accumulator of the group, can be `null` if it's the first `element` encountered in the group; * `element`: the element from the source being aggregated; * `first`: indicates whether it's the first `element` encountered in the group. If the [destination](aggregate-to#kotlin.collections%24aggregateTo(kotlin.collections.Grouping((kotlin.collections.aggregateTo.T,%20kotlin.collections.aggregateTo.K)),%20kotlin.collections.aggregateTo.M,%20kotlin.Function4((kotlin.collections.aggregateTo.K,%20kotlin.collections.aggregateTo.R?,%20kotlin.collections.aggregateTo.T,%20kotlin.Boolean,%20kotlin.collections.aggregateTo.R)))/destination) map already has a value corresponding to some key, then the elements being aggregated for that key are never considered as `first`. **Return** the [destination](aggregate-to#kotlin.collections%24aggregateTo(kotlin.collections.Grouping((kotlin.collections.aggregateTo.T,%20kotlin.collections.aggregateTo.K)),%20kotlin.collections.aggregateTo.M,%20kotlin.Function4((kotlin.collections.aggregateTo.K,%20kotlin.collections.aggregateTo.R?,%20kotlin.collections.aggregateTo.T,%20kotlin.Boolean,%20kotlin.collections.aggregateTo.R)))/destination) map associating the key of each group with the result of aggregation of the group elements. kotlin toShortArray toShortArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toShortArray](to-short-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Array<out Short>.toShortArray(): ShortArray ``` Returns an array of Short containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Collection<Short>.toShortArray(): ShortArray ``` Returns an array of Short containing all of the elements of this collection. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UShortArray.toShortArray(): ShortArray ``` Returns an array of type [ShortArray](../kotlin/-short-array/index#kotlin.ShortArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. kotlin indexOfLast indexOfLast =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [indexOfLast](index-of-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` ``` inline fun ByteArray.indexOfLast(     predicate: (Byte) -> Boolean ): Int ``` ``` inline fun ShortArray.indexOfLast(     predicate: (Short) -> Boolean ): Int ``` ``` inline fun IntArray.indexOfLast(     predicate: (Int) -> Boolean ): Int ``` ``` inline fun LongArray.indexOfLast(     predicate: (Long) -> Boolean ): Int ``` ``` inline fun FloatArray.indexOfLast(     predicate: (Float) -> Boolean ): Int ``` ``` inline fun DoubleArray.indexOfLast(     predicate: (Double) -> Boolean ): Int ``` ``` inline fun BooleanArray.indexOfLast(     predicate: (Boolean) -> Boolean ): Int ``` ``` inline fun CharArray.indexOfLast(     predicate: (Char) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.indexOfLast(     predicate: (UInt) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.indexOfLast(     predicate: (ULong) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.indexOfLast(     predicate: (UByte) -> Boolean ): Int ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.indexOfLast(     predicate: (UShort) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](index-of-last#kotlin.collections%24indexOfLast(kotlin.Array((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> List<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. kotlin runningFoldIndexed runningFoldIndexed ================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [runningFoldIndexed](running-fold-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Array<out T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` ``` inline fun <R> ByteArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> R ): List<R> ``` ``` inline fun <R> ShortArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> R ): List<R> ``` ``` inline fun <R> IntArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> R ): List<R> ``` ``` inline fun <R> LongArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> R ): List<R> ``` ``` inline fun <R> FloatArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> R ): List<R> ``` ``` inline fun <R> DoubleArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> R ): List<R> ``` ``` inline fun <R> BooleanArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> R ): List<R> ``` ``` inline fun <R> CharArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, ULong) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> R ): List<R> ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, UShort) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.Array((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with [initial](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.Array((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. Note that `acc` value passed to [operation](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.Array((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningFold("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.runningFoldIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().runningFold("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. Note that `acc` value passed to [operation](running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningFold("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.runningFoldIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().runningFold("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value.
programming_docs
kotlin stringMapOf stringMapOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [stringMapOf](string-map-of) **Platform and version requirements:** JS (1.1) ``` fun <V> stringMapOf(     vararg pairs: Pair<String, V> ): HashMap<String, V> ``` Constructs the specialized implementation of [HashMap](-hash-map/index#kotlin.collections.HashMap) with String keys, which stores the keys as properties of JS object without hashing them. kotlin none none ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <none> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.none(): Boolean ``` ``` fun ByteArray.none(): Boolean ``` ``` fun ShortArray.none(): Boolean ``` ``` fun IntArray.none(): Boolean ``` ``` fun LongArray.none(): Boolean ``` ``` fun FloatArray.none(): Boolean ``` ``` fun DoubleArray.none(): Boolean ``` ``` fun BooleanArray.none(): Boolean ``` ``` fun CharArray.none(): Boolean ``` ``` @ExperimentalUnsignedTypes fun UIntArray.none(): Boolean ``` ``` @ExperimentalUnsignedTypes fun ULongArray.none(): Boolean ``` ``` @ExperimentalUnsignedTypes fun UByteArray.none(): Boolean ``` ``` @ExperimentalUnsignedTypes fun UShortArray.none(): Boolean ``` Returns `true` if the array has no elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.none() is ${emptyList.none()}") // true val nonEmptyList = listOf("one", "two", "three") println("nonEmptyList.none() is ${nonEmptyList.none()}") // false //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.none(     predicate: (T) -> Boolean ): Boolean ``` ``` inline fun ByteArray.none(     predicate: (Byte) -> Boolean ): Boolean ``` ``` inline fun ShortArray.none(     predicate: (Short) -> Boolean ): Boolean ``` ``` inline fun IntArray.none(     predicate: (Int) -> Boolean ): Boolean ``` ``` inline fun LongArray.none(     predicate: (Long) -> Boolean ): Boolean ``` ``` inline fun FloatArray.none(     predicate: (Float) -> Boolean ): Boolean ``` ``` inline fun DoubleArray.none(     predicate: (Double) -> Boolean ): Boolean ``` ``` inline fun BooleanArray.none(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.none(     predicate: (Char) -> Boolean ): Boolean ``` ``` inline fun <T> Iterable<T>.none(     predicate: (T) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.none(     predicate: (UInt) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.none(     predicate: (ULong) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.none(     predicate: (UByte) -> Boolean ): Boolean ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.none(     predicate: (UShort) -> Boolean ): Boolean ``` Returns `true` if no elements match the given [predicate](none#kotlin.collections%24none(kotlin.Array((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.none { isEven(it) } is ${zeroToTen.none { isEven(it) }}") // false println("zeroToTen.none(isEven) is ${zeroToTen.none(isEven)}") // false val odds = zeroToTen.map { it * 2 + 1 } println("odds.none { isEven(it) } is ${odds.none { isEven(it) }}") // true val emptyList = emptyList<Int>() println("emptyList.none { true } is ${emptyList.none { true }}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if the collection has no elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.none() is ${emptyList.none()}") // true val nonEmptyList = listOf("one", "two", "three") println("nonEmptyList.none() is ${nonEmptyList.none()}") // false //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<out K, V>.none(): Boolean ``` Returns `true` if the map has no entries. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.none() is ${emptyList.none()}") // true val nonEmptyList = listOf("one", "two", "three") println("nonEmptyList.none() is ${nonEmptyList.none()}") // false //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.none(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` Returns `true` if no entries match the given [predicate](none#kotlin.collections%24none(kotlin.collections.Map((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.none { isEven(it) } is ${zeroToTen.none { isEven(it) }}") // false println("zeroToTen.none(isEven) is ${zeroToTen.none(isEven)}") // false val odds = zeroToTen.map { it * 2 + 1 } println("odds.none { isEven(it) } is ${odds.none { isEven(it) }}") // true val emptyList = emptyList<Int>() println("emptyList.none { true } is ${emptyList.none { true }}") // true //sampleEnd } ``` kotlin maxByOrNull maxByOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxByOrNull](max-by-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Array<out T>.maxByOrNull(     selector: (T) -> R ): T? ``` ``` inline fun <R : Comparable<R>> ByteArray.maxByOrNull(     selector: (Byte) -> R ): Byte? ``` ``` inline fun <R : Comparable<R>> ShortArray.maxByOrNull(     selector: (Short) -> R ): Short? ``` ``` inline fun <R : Comparable<R>> IntArray.maxByOrNull(     selector: (Int) -> R ): Int? ``` ``` inline fun <R : Comparable<R>> LongArray.maxByOrNull(     selector: (Long) -> R ): Long? ``` ``` inline fun <R : Comparable<R>> FloatArray.maxByOrNull(     selector: (Float) -> R ): Float? ``` ``` inline fun <R : Comparable<R>> DoubleArray.maxByOrNull(     selector: (Double) -> R ): Double? ``` ``` inline fun <R : Comparable<R>> BooleanArray.maxByOrNull(     selector: (Boolean) -> R ): Boolean? ``` ``` inline fun <R : Comparable<R>> CharArray.maxByOrNull(     selector: (Char) -> R ): Char? ``` ``` inline fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.maxByOrNull(     selector: (UInt) -> R ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.maxByOrNull(     selector: (ULong) -> R ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.maxByOrNull(     selector: (UByte) -> R ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.maxByOrNull(     selector: (UShort) -> R ): UShort? ``` Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToAge = listOf("Alice" to 42, "Bob" to 28, "Carol" to 51) val oldestPerson = nameToAge.maxByOrNull { it.second } println(oldestPerson) // (Carol, 51) val emptyList = emptyList<Pair<String, Int>>() val emptyMax = emptyList.maxByOrNull { it.second } println(emptyMax) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` Returns the first entry yielding the largest value of the given function or `null` if there are no entries. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToAge = listOf("Alice" to 42, "Bob" to 28, "Carol" to 51) val oldestPerson = nameToAge.maxByOrNull { it.second } println(oldestPerson) // (Carol, 51) val emptyList = emptyList<Pair<String, Int>>() val emptyMax = emptyList.maxByOrNull { it.second } println(emptyMax) // null //sampleEnd } ``` kotlin maxOrNull maxOrNull ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxOrNull](max-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Array<out Double>.maxOrNull(): Double? ``` ``` fun Array<out Float>.maxOrNull(): Float? ``` ``` fun FloatArray.maxOrNull(): Float? ``` ``` fun DoubleArray.maxOrNull(): Double? ``` ``` fun Iterable<Double>.maxOrNull(): Double? ``` ``` fun Iterable<Float>.maxOrNull(): Float? ``` Returns the largest element or `null` if there are no elements. If any of elements is `NaN` returns `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Comparable<T>> Array<out T>.maxOrNull(): T? ``` ``` fun ByteArray.maxOrNull(): Byte? ``` ``` fun ShortArray.maxOrNull(): Short? ``` ``` fun IntArray.maxOrNull(): Int? ``` ``` fun LongArray.maxOrNull(): Long? ``` ``` fun CharArray.maxOrNull(): Char? ``` ``` fun <T : Comparable<T>> Iterable<T>.maxOrNull(): T? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.maxOrNull(): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.maxOrNull(): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.maxOrNull(): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.maxOrNull(): UShort? ``` Returns the largest element or `null` if there are no elements. kotlin component5 component5 ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <component5> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Array<out T>.component5(): T ``` ``` operator fun ByteArray.component5(): Byte ``` ``` operator fun ShortArray.component5(): Short ``` ``` operator fun IntArray.component5(): Int ``` ``` operator fun LongArray.component5(): Long ``` ``` operator fun FloatArray.component5(): Float ``` ``` operator fun DoubleArray.component5(): Double ``` ``` operator fun BooleanArray.component5(): Boolean ``` ``` operator fun CharArray.component5(): Char ``` ``` @ExperimentalUnsignedTypes operator fun UIntArray.component5(): UInt ``` ``` @ExperimentalUnsignedTypes operator fun ULongArray.component5(): ULong ``` ``` @ExperimentalUnsignedTypes operator fun UByteArray.component5(): UByte ``` ``` @ExperimentalUnsignedTypes operator fun UShortArray.component5(): UShort ``` Returns 5th *element* from the array. If the size of this array is less than 5, throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) except in Kotlin/JS where the behavior is unspecified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> List<T>.component5(): T ``` Returns 5th *element* from the list. Throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the size of this list is less than 5. kotlin findLast findLast ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [findLast](find-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.findLast(     predicate: (T) -> Boolean ): T? ``` ``` inline fun ByteArray.findLast(     predicate: (Byte) -> Boolean ): Byte? ``` ``` inline fun ShortArray.findLast(     predicate: (Short) -> Boolean ): Short? ``` ``` inline fun IntArray.findLast(     predicate: (Int) -> Boolean ): Int? ``` ``` inline fun LongArray.findLast(     predicate: (Long) -> Boolean ): Long? ``` ``` inline fun FloatArray.findLast(     predicate: (Float) -> Boolean ): Float? ``` ``` inline fun DoubleArray.findLast(     predicate: (Double) -> Boolean ): Double? ``` ``` inline fun BooleanArray.findLast(     predicate: (Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.findLast(     predicate: (Char) -> Boolean ): Char? ``` ``` inline fun <T> Iterable<T>.findLast(     predicate: (T) -> Boolean ): T? ``` ``` inline fun <T> List<T>.findLast(     predicate: (T) -> Boolean ): T? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.findLast(     predicate: (UInt) -> Boolean ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.findLast(     predicate: (ULong) -> Boolean ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.findLast(     predicate: (UByte) -> Boolean ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.findLast(     predicate: (UShort) -> Boolean ): UShort? ``` Returns the last element matching the given [predicate](find-last#kotlin.collections%24findLast(kotlin.Array((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3, 4, 5, 6, 7) val firstOdd = numbers.find { it % 2 != 0 } val lastEven = numbers.findLast { it % 2 == 0 } println(firstOdd) // 1 println(lastEven) // 6 //sampleEnd } ``` kotlin fold fold ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <fold> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Array<out T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` ``` inline fun <R> ByteArray.fold(     initial: R,     operation: (acc: R, Byte) -> R ): R ``` ``` inline fun <R> ShortArray.fold(     initial: R,     operation: (acc: R, Short) -> R ): R ``` ``` inline fun <R> IntArray.fold(     initial: R,     operation: (acc: R, Int) -> R ): R ``` ``` inline fun <R> LongArray.fold(     initial: R,     operation: (acc: R, Long) -> R ): R ``` ``` inline fun <R> FloatArray.fold(     initial: R,     operation: (acc: R, Float) -> R ): R ``` ``` inline fun <R> DoubleArray.fold(     initial: R,     operation: (acc: R, Double) -> R ): R ``` ``` inline fun <R> BooleanArray.fold(     initial: R,     operation: (acc: R, Boolean) -> R ): R ``` ``` inline fun <R> CharArray.fold(     initial: R,     operation: (acc: R, Char) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.fold(     initial: R,     operation: (acc: R, UInt) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.fold(     initial: R,     operation: (acc: R, ULong) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.fold(     initial: R,     operation: (acc: R, UByte) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.fold(     initial: R,     operation: (acc: R, UShort) -> R ): R ``` Accumulates value starting with [initial](fold#kotlin.collections%24fold(kotlin.Array((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](fold#kotlin.collections%24fold(kotlin.Array((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. Returns the specified [initial](fold#kotlin.collections%24fold(kotlin.Array((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value if the array is empty. Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` Accumulates value starting with [initial](fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. Returns the specified [initial](fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value if the collection is empty. Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K, R> Grouping<T, K>.fold(     initialValueSelector: (key: K, element: T) -> R,     operation: (key: K, accumulator: R, element: T) -> R ): Map<K, R> ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.Function2((kotlin.collections.fold.K,%20kotlin.collections.fold.T,%20kotlin.collections.fold.R)),%20kotlin.Function3((kotlin.collections.fold.K,%20kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is provided by [initialValueSelector](fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.Function2((kotlin.collections.fold.K,%20kotlin.collections.fold.T,%20kotlin.collections.fold.R)),%20kotlin.Function3((kotlin.collections.fold.K,%20kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initialValueSelector) function. ``` fun main(args: Array<String>) { //sampleStart val fruits = listOf("cherry", "blueberry", "citrus", "apple", "apricot", "banana", "coconut") val evenFruits = fruits.groupingBy { it.first() } .fold({ key, _ -> key to mutableListOf<String>() }, { _, accumulator, element -> accumulator.also { (_, list) -> if (element.length % 2 == 0) list.add(element) } }) val sorted = evenFruits.values.sortedBy { it.first } println(sorted) // [(a, []), (b, [banana]), (c, [cherry, citrus])] //sampleEnd } ``` Parameters ---------- `initialValueSelector` - a function that provides an initial value of accumulator for each group. It's invoked with parameters: `operation` - a function that is invoked on each element with the following parameters: **Return** a [Map](-map/index#kotlin.collections.Map) associating the key of each group with the result of accumulating the group elements. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K, R> Grouping<T, K>.fold(     initialValue: R,     operation: (accumulator: R, element: T) -> R ): Map<K, R> ``` Groups elements from the [Grouping](-grouping/index) source by key and applies [operation](fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the same [initialValue](fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initialValue) for each group. ``` fun main(args: Array<String>) { //sampleStart val fruits = listOf("apple", "apricot", "banana", "blueberry", "cherry", "coconut") // collect only even length Strings val evenFruits = fruits.groupingBy { it.first() } .fold(listOf<String>()) { acc, e -> if (e.length % 2 == 0) acc + e else acc } println(evenFruits) // {a=[], b=[banana], c=[cherry]} //sampleEnd } ``` Parameters ---------- `operation` - a function that is invoked on each element with the following parameters: **Return** a [Map](-map/index#kotlin.collections.Map) associating the key of each group with the result of accumulating the group elements.
programming_docs
kotlin asShortArray asShortArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asShortArray](as-short-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UShortArray.asShortArray(): ShortArray ``` Returns an array of type [ShortArray](../kotlin/-short-array/index#kotlin.ShortArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. kotlin minOrNull minOrNull ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minOrNull](min-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Array<out Double>.minOrNull(): Double? ``` ``` fun Array<out Float>.minOrNull(): Float? ``` ``` fun FloatArray.minOrNull(): Float? ``` ``` fun DoubleArray.minOrNull(): Double? ``` ``` fun Iterable<Double>.minOrNull(): Double? ``` ``` fun Iterable<Float>.minOrNull(): Float? ``` Returns the smallest element or `null` if there are no elements. If any of elements is `NaN` returns `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Comparable<T>> Array<out T>.minOrNull(): T? ``` ``` fun ByteArray.minOrNull(): Byte? ``` ``` fun ShortArray.minOrNull(): Short? ``` ``` fun IntArray.minOrNull(): Int? ``` ``` fun LongArray.minOrNull(): Long? ``` ``` fun CharArray.minOrNull(): Char? ``` ``` fun <T : Comparable<T>> Iterable<T>.minOrNull(): T? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.minOrNull(): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.minOrNull(): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.minOrNull(): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.minOrNull(): UShort? ``` Returns the smallest element or `null` if there are no elements. kotlin minus minus ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection without the first occurrence of the given [element](minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.minus(element: T): Set<T> ``` Returns a set containing all elements of the original set except the given [element](minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> ``` Returns a map containing all entries of the original map except the entry with the given [key](minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.minus.K)/key). The returned map preserves the entry iteration order of the original map. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun <K, V> Map<out K, V>.minus(     keys: Iterable<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.Iterable((kotlin.collections.minus.K)))/keys) collection. The returned map preserves the entry iteration order of the original map. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun <K, V> Map<out K, V>.minus(     keys: Array<out K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.Array((kotlin.collections.minus.K)))/keys) array. The returned map preserves the entry iteration order of the original map. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun <K, V> Map<out K, V>.minus(     keys: Sequence<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.sequences.Sequence((kotlin.collections.minus.K)))/keys) sequence. The returned map preserves the entry iteration order of the original map. kotlin filterIndexedTo filterIndexedTo =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterIndexedTo](filter-indexed-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, C : MutableCollection<in T>> Array<out T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Byte>> ByteArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Byte) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Short>> ShortArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Short) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Int>> IntArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Int) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Long>> LongArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Long) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Float>> FloatArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Float) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Double>> DoubleArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Double) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Boolean) -> Boolean ): C ``` ``` inline fun <C : MutableCollection<in Char>> CharArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Char) -> Boolean ): C ``` ``` inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UInt>> UIntArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UInt) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in ULong>> ULongArray.filterIndexedTo(     destination: C,     predicate: (index: Int, ULong) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UByte>> UByteArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UByte) -> Boolean ): C ``` ``` @ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UShort>> UShortArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UShort) -> Boolean ): C ``` Appends all elements matching the given [predicate](filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.Array((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.Array((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(0, 1, 2, 3, 4, 8, 6) val numbersOnSameIndexAsValue = mutableListOf<Int>() println(numbersOnSameIndexAsValue) // [] numbers.filterIndexedTo(numbersOnSameIndexAsValue) { index, i -> index == i } println(numbersOnSameIndexAsValue) // [0, 1, 2, 3, 4, 6] //sampleEnd } ``` Parameters ---------- `predicate` - function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element. kotlin mapIndexedNotNullTo mapIndexedNotNullTo =================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapIndexedNotNullTo](map-indexed-not-null-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any, C : MutableCollection<in R>> Array<out T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` Applies the given [transform](map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.Array((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original array and appends only the non-null results to the given [destination](map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.Array((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` Applies the given [transform](map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. kotlin elementAt elementAt ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [elementAt](element-at) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.elementAt(index: Int): T ``` ``` fun ByteArray.elementAt(index: Int): Byte ``` ``` fun ShortArray.elementAt(index: Int): Short ``` ``` fun IntArray.elementAt(index: Int): Int ``` ``` fun LongArray.elementAt(index: Int): Long ``` ``` fun FloatArray.elementAt(index: Int): Float ``` ``` fun DoubleArray.elementAt(index: Int): Double ``` ``` fun BooleanArray.elementAt(index: Int): Boolean ``` ``` fun CharArray.elementAt(index: Int): Char ``` ``` @ExperimentalUnsignedTypes fun UIntArray.elementAt(     index: Int ): UInt ``` ``` @ExperimentalUnsignedTypes fun ULongArray.elementAt(     index: Int ): ULong ``` ``` @ExperimentalUnsignedTypes fun UByteArray.elementAt(     index: Int ): UByte ``` ``` @ExperimentalUnsignedTypes fun UShortArray.elementAt(     index: Int ): UShort ``` Returns an element at the given [index](element-at#kotlin.collections%24elementAt(kotlin.Array((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.collections%24elementAt(kotlin.Array((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAt(0)) // 1 println(list.elementAt(2)) // 3 // list.elementAt(3) // will fail with IndexOutOfBoundsException val emptyList = emptyList<Int>() // emptyList.elementAt(0) // will fail with IndexOutOfBoundsException //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` Returns an element at the given [index](element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAt(0)) // 1 println(list.elementAt(2)) // 3 // list.elementAt(3) // will fail with IndexOutOfBoundsException val emptyList = emptyList<Int>() // emptyList.elementAt(0) // will fail with IndexOutOfBoundsException //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.elementAt(index: Int): T ``` Returns an element at the given [index](element-at#kotlin.collections%24elementAt(kotlin.collections.List((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.collections%24elementAt(kotlin.collections.List((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAt(0)) // 1 println(list.elementAt(2)) // 3 // list.elementAt(3) // will fail with IndexOutOfBoundsException val emptyList = emptyList<Int>() // emptyList.elementAt(0) // will fail with IndexOutOfBoundsException //sampleEnd } ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.isEmpty(): Boolean ``` ``` fun ByteArray.isEmpty(): Boolean ``` ``` fun ShortArray.isEmpty(): Boolean ``` ``` fun IntArray.isEmpty(): Boolean ``` ``` fun LongArray.isEmpty(): Boolean ``` ``` fun FloatArray.isEmpty(): Boolean ``` ``` fun DoubleArray.isEmpty(): Boolean ``` ``` fun BooleanArray.isEmpty(): Boolean ``` ``` fun CharArray.isEmpty(): Boolean ``` Returns `true` if the array is empty. kotlin asReversed asReversed ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asReversed](as-reversed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.asReversed(): List<T> ``` Returns a reversed read-only view of the original List. All changes made in the original list will be reflected in the reversed one. ``` fun main(args: Array<String>) { //sampleStart val original = mutableListOf('a', 'b', 'c', 'd', 'e') val originalReadOnly = original as List<Char> val reversed = originalReadOnly.asReversed() println(original) // [a, b, c, d, e] println(reversed) // [e, d, c, b, a] // changing the original list affects its reversed view original.add('f') println(original) // [a, b, c, d, e, f] println(reversed) // [f, e, d, c, b, a] original[original.lastIndex] = 'z' println(original) // [a, b, c, d, e, z] println(reversed) // [z, e, d, c, b, a] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("asReversedMutable") fun <T> MutableList<T>.asReversed(): MutableList<T> ``` Returns a reversed mutable view of the original mutable List. All changes made in the original list will be reflected in the reversed one and vice versa. ``` fun main(args: Array<String>) { //sampleStart val original = mutableListOf(1, 2, 3, 4, 5) val reversed = original.asReversed() println(original) // [1, 2, 3, 4, 5] println(reversed) // [5, 4, 3, 2, 1] // changing the reversed view affects the original list reversed.add(0) println(original) // [0, 1, 2, 3, 4, 5] println(reversed) // [5, 4, 3, 2, 1, 0] // changing the original list affects its reversed view original[2] = -original[2] println(original) // [0, 1, -2, 3, 4, 5] println(reversed) // [5, 4, 3, -2, 1, 0] //sampleEnd } ```
programming_docs
kotlin containsValue containsValue ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [containsValue](contains-value) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> Map<K, V>.containsValue(value: V): Boolean ``` Returns `true` if the map maps one or more keys to the specified [value](contains-value#kotlin.collections%24containsValue(kotlin.collections.Map((kotlin.collections.containsValue.K,%20kotlin.collections.containsValue.V)),%20kotlin.collections.containsValue.V)/value). Allows to overcome type-safety restriction of `containsValue` that requires to pass a value of type `V`. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map: Map<String, Int> = mapOf("x" to 1, "y" to 2) // member containsValue is used println("map.containsValue(1) is ${map.containsValue(1)}") // true // extension containsValue is used when the argument type is a supertype of the map value type println("map.containsValue(1 as Number) is ${map.containsValue(1 as Number)}") // true println("map.containsValue(2 as Any) is ${map.containsValue(2 as Any)}") // true println("map.containsValue(\"string\" as Any) is ${map.containsValue("string" as Any)}") // false // map.containsValue("string") // cannot call extension when the argument type and the map value type are unrelated at all //sampleEnd } ``` kotlin contentHashCode contentHashCode =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [contentHashCode](content-hash-code) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun <T> Array<out T>.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun ByteArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun ShortArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun IntArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun LongArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun FloatArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun DoubleArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun BooleanArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun CharArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun <T> Array<out T>?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun <T> Array<out T>?.contentHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun ByteArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun ByteArray?.contentHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun ShortArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun ShortArray?.contentHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun IntArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun IntArray?.contentHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun LongArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun LongArray?.contentHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun FloatArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun FloatArray?.contentHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun DoubleArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun DoubleArray?.contentHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun BooleanArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun BooleanArray?.contentHashCode(): Int ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun CharArray?.contentHashCode(): Int ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentHashCodeNullable") fun CharArray?.contentHashCode(): Int ``` Returns a hash code based on the contents of this array as if it is [List](-list/index#kotlin.collections.List). **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes fun UIntArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes fun ULongArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes fun UByteArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes fun UShortArray.contentHashCode(): Int ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @ExperimentalUnsignedTypes fun UIntArray?.contentHashCode(): Int ``` ``` @ExperimentalUnsignedTypes fun ULongArray?.contentHashCode(): Int ``` ``` @ExperimentalUnsignedTypes fun UByteArray?.contentHashCode(): Int ``` ``` @ExperimentalUnsignedTypes fun UShortArray?.contentHashCode(): Int ``` Returns a hash code based on the contents of this array as if it is [List](-list/index#kotlin.collections.List). kotlin intersect intersect ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <intersect> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T> Array<out T>.intersect(     other: Iterable<T> ): Set<T> ``` ``` infix fun ByteArray.intersect(     other: Iterable<Byte> ): Set<Byte> ``` ``` infix fun ShortArray.intersect(     other: Iterable<Short> ): Set<Short> ``` ``` infix fun IntArray.intersect(other: Iterable<Int>): Set<Int> ``` ``` infix fun LongArray.intersect(     other: Iterable<Long> ): Set<Long> ``` ``` infix fun FloatArray.intersect(     other: Iterable<Float> ): Set<Float> ``` ``` infix fun DoubleArray.intersect(     other: Iterable<Double> ): Set<Double> ``` ``` infix fun BooleanArray.intersect(     other: Iterable<Boolean> ): Set<Boolean> ``` ``` infix fun CharArray.intersect(     other: Iterable<Char> ): Set<Char> ``` Returns a set containing all elements that are contained by both this array and the specified collection. The returned set preserves the element iteration order of the original array. To get a set containing all elements that are contained at least in one of these collections use <union>. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` Returns a set containing all elements that are contained by both this collection and the specified collection. The returned set preserves the element iteration order of the original collection. To get a set containing all elements that are contained at least in one of these collections use <union>. kotlin foldRight foldRight ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [foldRight](fold-right) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Array<out T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` ``` inline fun <R> ByteArray.foldRight(     initial: R,     operation: (Byte, acc: R) -> R ): R ``` ``` inline fun <R> ShortArray.foldRight(     initial: R,     operation: (Short, acc: R) -> R ): R ``` ``` inline fun <R> IntArray.foldRight(     initial: R,     operation: (Int, acc: R) -> R ): R ``` ``` inline fun <R> LongArray.foldRight(     initial: R,     operation: (Long, acc: R) -> R ): R ``` ``` inline fun <R> FloatArray.foldRight(     initial: R,     operation: (Float, acc: R) -> R ): R ``` ``` inline fun <R> DoubleArray.foldRight(     initial: R,     operation: (Double, acc: R) -> R ): R ``` ``` inline fun <R> BooleanArray.foldRight(     initial: R,     operation: (Boolean, acc: R) -> R ): R ``` ``` inline fun <R> CharArray.foldRight(     initial: R,     operation: (Char, acc: R) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.foldRight(     initial: R,     operation: (UInt, acc: R) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.foldRight(     initial: R,     operation: (ULong, acc: R) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.foldRight(     initial: R,     operation: (UByte, acc: R) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.foldRight(     initial: R,     operation: (UShort, acc: R) -> R ): R ``` Accumulates value starting with [initial](fold-right#kotlin.collections%24foldRight(kotlin.Array((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](fold-right#kotlin.collections%24foldRight(kotlin.Array((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. Returns the specified [initial](fold-right#kotlin.collections%24foldRight(kotlin.Array((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value if the array is empty. Parameters ---------- `operation` - function that takes an element and current accumulator value, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` Accumulates value starting with [initial](fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. Returns the specified [initial](fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value if the list is empty. Parameters ---------- `operation` - function that takes an element and current accumulator value, and calculates the next accumulator value. kotlin copyOfRange copyOfRange =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [copyOfRange](copy-of-range) **Platform and version requirements:** Native (1.3) ``` fun <T> Array<T>.copyOfRange(     fromIndex: Int,     toIndex: Int ): Array<T> ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun <T> Array<T>.copyOfRange(     fromIndex: Int,     toIndex: Int ): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> Array<out T>.copyOfRange(     fromIndex: Int,     toIndex: Int ): Array<T> ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun ByteArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ByteArray ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun ByteArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ByteArray ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun ShortArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ShortArray ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun ShortArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ShortArray ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun IntArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): IntArray ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun IntArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): IntArray ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun LongArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): LongArray ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun LongArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): LongArray ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun FloatArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): FloatArray ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun FloatArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): FloatArray ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun DoubleArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): DoubleArray ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun DoubleArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): DoubleArray ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun BooleanArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): BooleanArray ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun BooleanArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): BooleanArray ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun CharArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): CharArray ``` **Platform and version requirements:** JVM (1.0) ``` @JvmName("copyOfRangeInline") fun CharArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): CharArray ``` Returns a new array which is a copy of the specified range of the original array. Parameters ---------- `fromIndex` - the start of the range (inclusive) to copy. `toIndex` - the end of the range (exclusive) to copy. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](copy-of-range#kotlin.collections%24copyOfRange(kotlin.Array((kotlin.collections.copyOfRange.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](copy-of-range#kotlin.collections%24copyOfRange(kotlin.Array((kotlin.collections.copyOfRange.T)),%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](copy-of-range#kotlin.collections%24copyOfRange(kotlin.Array((kotlin.collections.copyOfRange.T)),%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](copy-of-range#kotlin.collections%24copyOfRange(kotlin.Array((kotlin.collections.copyOfRange.T)),%20kotlin.Int,%20kotlin.Int)/toIndex). **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UIntArray ``` ``` @ExperimentalUnsignedTypes fun ULongArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): ULongArray ``` ``` @ExperimentalUnsignedTypes fun UByteArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UByteArray ``` ``` @ExperimentalUnsignedTypes fun UShortArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UShortArray ``` Returns a new array which is a copy of the specified range of the original array. Parameters ---------- `fromIndex` - the start of the range (inclusive) to copy. `toIndex` - the end of the range (exclusive) to copy. Exceptions ---------- `IndexOutOfBoundsException` - if [fromIndex](copy-of-range#kotlin.collections%24copyOfRange(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int)/fromIndex) is less than zero or [toIndex](copy-of-range#kotlin.collections%24copyOfRange(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int)/toIndex) is greater than the size of this array. `IllegalArgumentException` - if [fromIndex](copy-of-range#kotlin.collections%24copyOfRange(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int)/fromIndex) is greater than [toIndex](copy-of-range#kotlin.collections%24copyOfRange(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Int)/toIndex). kotlin addAll addAll ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [addAll](add-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` Adds all elements of the given [elements](add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](-mutable-collection/index#kotlin.collections.MutableCollection).
programming_docs
kotlin joinToString joinToString ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [joinToString](join-to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` ``` fun ByteArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Byte) -> CharSequence)? = null ): String ``` ``` fun ShortArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Short) -> CharSequence)? = null ): String ``` ``` fun IntArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Int) -> CharSequence)? = null ): String ``` ``` fun LongArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Long) -> CharSequence)? = null ): String ``` ``` fun FloatArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Float) -> CharSequence)? = null ): String ``` ``` fun DoubleArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Double) -> CharSequence)? = null ): String ``` ``` fun BooleanArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Boolean) -> CharSequence)? = null ): String ``` ``` fun CharArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Char) -> CharSequence)? = null ): String ``` ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` Creates a string from all the elements separated using [separator](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. If the collection could be huge, you can specify a non-negative value of [limit](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/limit), in which case only the first [limit](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/limit) elements will be appended, followed by the [truncated](join-to-string#kotlin.collections%24joinToString(kotlin.Array((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/truncated) string (which defaults to "..."). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3, 4, 5, 6) println(numbers.joinToString()) // 1, 2, 3, 4, 5, 6 println(numbers.joinToString(prefix = "[", postfix = "]")) // [1, 2, 3, 4, 5, 6] println(numbers.joinToString(prefix = "<", postfix = ">", separator = "•")) // <1•2•3•4•5•6> val chars = charArrayOf('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q') println(chars.joinToString(limit = 5, truncated = "...!") { it.uppercaseChar().toString() }) // A, B, C, D, E, ...! //sampleEnd } ``` kotlin maxOfWith maxOfWith ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [maxOfWith](max-of-with) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Array<out T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` ``` inline fun <R> ByteArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Byte) -> R ): R ``` ``` inline fun <R> ShortArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Short) -> R ): R ``` ``` inline fun <R> IntArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Int) -> R ): R ``` ``` inline fun <R> LongArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Long) -> R ): R ``` ``` inline fun <R> FloatArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Float) -> R ): R ``` ``` inline fun <R> DoubleArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Double) -> R ): R ``` ``` inline fun <R> BooleanArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R ``` ``` inline fun <R> CharArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Char) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UInt) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.maxOfWith(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UByte) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UShort) -> R ): R ``` Returns the largest value according to the provided [comparator](max-of-with#kotlin.collections%24maxOfWith(kotlin.Array((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.collections%24maxOfWith(kotlin.Array((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` Returns the largest value according to the provided [comparator](max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R> Map<out K, V>.maxOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` Returns the largest value according to the provided [comparator](max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/selector) function applied to each entry in the map. Exceptions ---------- `NoSuchElementException` - if the map is empty. kotlin minOfWith minOfWith ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minOfWith](min-of-with) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Array<out T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` ``` inline fun <R> ByteArray.minOfWith(     comparator: Comparator<in R>,     selector: (Byte) -> R ): R ``` ``` inline fun <R> ShortArray.minOfWith(     comparator: Comparator<in R>,     selector: (Short) -> R ): R ``` ``` inline fun <R> IntArray.minOfWith(     comparator: Comparator<in R>,     selector: (Int) -> R ): R ``` ``` inline fun <R> LongArray.minOfWith(     comparator: Comparator<in R>,     selector: (Long) -> R ): R ``` ``` inline fun <R> FloatArray.minOfWith(     comparator: Comparator<in R>,     selector: (Float) -> R ): R ``` ``` inline fun <R> DoubleArray.minOfWith(     comparator: Comparator<in R>,     selector: (Double) -> R ): R ``` ``` inline fun <R> BooleanArray.minOfWith(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R ``` ``` inline fun <R> CharArray.minOfWith(     comparator: Comparator<in R>,     selector: (Char) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UIntArray.minOfWith(     comparator: Comparator<in R>,     selector: (UInt) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> ULongArray.minOfWith(     comparator: Comparator<in R>,     selector: (ULong) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UByteArray.minOfWith(     comparator: Comparator<in R>,     selector: (UByte) -> R ): R ``` ``` @ExperimentalUnsignedTypes inline fun <R> UShortArray.minOfWith(     comparator: Comparator<in R>,     selector: (UShort) -> R ): R ``` Returns the smallest value according to the provided [comparator](min-of-with#kotlin.collections%24minOfWith(kotlin.Array((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.collections%24minOfWith(kotlin.Array((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` Returns the smallest value according to the provided [comparator](min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R> Map<out K, V>.minOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` Returns the smallest value according to the provided [comparator](min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/selector) function applied to each entry in the map. Exceptions ---------- `NoSuchElementException` - if the map is empty. kotlin removeLastOrNull removeLastOrNull ================ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [removeLastOrNull](remove-last-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> MutableList<T>.removeLastOrNull(): T? ``` Removes the last element from this mutable list and returns that removed element, or returns `null` if this list is empty. kotlin putAll putAll ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [putAll](put-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Array<out Pair<K, V>>) ``` Puts all the given [pairs](put-all#kotlin.collections%24putAll(kotlin.collections.MutableMap((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)))))/pairs) into this [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Iterable<Pair<K, V>>) ``` Puts all the elements of the given collection into this [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Sequence<Pair<K, V>>) ``` Puts all the elements of the given sequence into this [MutableMap](-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. kotlin chunked chunked ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <chunked> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into a list of lists each not exceeding the given [size](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). The last list in the resulting list may have fewer elements than the given [size](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = "one two three four five six seven eight nine ten".split(' ') val chunks = words.chunked(3) println(chunks) // [[one, two, three], [four, five, six], [seven, eight, nine], [ten]] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` Splits this collection into several lists each not exceeding the given [size](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine") val dnaFragment = "ATTCGCGGCCGCCAA" val proteins = dnaFragment.chunked(3) { codon: CharSequence -> codonTable[codon.toString()] ?: error("Unknown codon") } println(proteins) // [Isoleucine, Arginine, Glycine, Arginine, Glutamine] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection. **Return** list of results of the [transform](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) applied to an each list. Note that the list passed to the [transform](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function is ephemeral and is valid only inside that function. You should not store it or allow it to escape in some way, unless you made a snapshot of it. The last list may have fewer elements than the given [size](chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size).
programming_docs
kotlin indexOf indexOf ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [indexOf](index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.indexOf(element: T): Int ``` ``` fun ByteArray.indexOf(element: Byte): Int ``` ``` fun ShortArray.indexOf(element: Short): Int ``` ``` fun IntArray.indexOf(element: Int): Int ``` ``` fun LongArray.indexOf(element: Long): Int ``` ``` @DeprecatedSinceKotlin("1.4", "1.6", "1.7") fun FloatArray.indexOf(     element: Float ): Int ``` **Deprecated:** The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list. ``` @DeprecatedSinceKotlin("1.4", "1.6", "1.7") fun DoubleArray.indexOf(     element: Double ): Int ``` **Deprecated:** The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list. ``` fun BooleanArray.indexOf(element: Boolean): Int ``` ``` fun CharArray.indexOf(element: Char): Int ``` ``` @ExperimentalUnsignedTypes fun UIntArray.indexOf(     element: UInt ): Int ``` ``` @ExperimentalUnsignedTypes fun ULongArray.indexOf(     element: ULong ): Int ``` ``` @ExperimentalUnsignedTypes fun UByteArray.indexOf(     element: UByte ): Int ``` ``` @ExperimentalUnsignedTypes fun UShortArray.indexOf(     element: UShort ): Int ``` Returns first index of [element](index-of#kotlin.collections%24indexOf(kotlin.Array((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the array does not contain element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` Returns first index of [element](index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.indexOf(element: T): Int ``` Returns first index of [element](index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. kotlin toLongArray toLongArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toLongArray](to-long-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Array<out Long>.toLongArray(): LongArray ``` Returns an array of Long containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Collection<Long>.toLongArray(): LongArray ``` Returns an array of Long containing all of the elements of this collection. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ULongArray.toLongArray(): LongArray ``` Returns an array of type [LongArray](../kotlin/-long-array/index#kotlin.LongArray), which is a copy of this array where each element is a signed reinterpretation of the corresponding element of this array. kotlin contentToString contentToString =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [contentToString](content-to-string) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun <T> Array<out T>.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun ByteArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun ShortArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun IntArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun LongArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun FloatArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun DoubleArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun BooleanArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @DeprecatedSinceKotlin("1.4") fun CharArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun <T> Array<out T>?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun <T> Array<out T>?.contentToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun ByteArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun ByteArray?.contentToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun ShortArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun ShortArray?.contentToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun IntArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun IntArray?.contentToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun LongArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun LongArray?.contentToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun FloatArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun FloatArray?.contentToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun DoubleArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun DoubleArray?.contentToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun BooleanArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun BooleanArray?.contentToString(): String ``` **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun CharArray?.contentToString(): String ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("contentToStringNullable") fun CharArray?.contentToString(): String ``` Returns a string representation of the contents of the specified array as if it is [List](-list/index#kotlin.collections.List). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf("apples", "oranges", "lime") println(array.contentToString()) // [apples, oranges, lime] //sampleEnd } ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes fun UIntArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes fun ULongArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes fun UByteArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @DeprecatedSinceKotlin("1.4") @ExperimentalUnsignedTypes fun UShortArray.contentToString(): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. ``` @ExperimentalUnsignedTypes fun UIntArray?.contentToString(): String ``` ``` @ExperimentalUnsignedTypes fun ULongArray?.contentToString(): String ``` ``` @ExperimentalUnsignedTypes fun UByteArray?.contentToString(): String ``` ``` @ExperimentalUnsignedTypes fun UShortArray?.contentToString(): String ``` Returns a string representation of the contents of the specified array as if it is [List](-list/index#kotlin.collections.List). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf("apples", "oranges", "lime") println(array.contentToString()) // [apples, oranges, lime] //sampleEnd } ``` kotlin associate associate ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <associate> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Array<out T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` ``` inline fun <K, V> ByteArray.associate(     transform: (Byte) -> Pair<K, V> ): Map<K, V> ``` ``` inline fun <K, V> ShortArray.associate(     transform: (Short) -> Pair<K, V> ): Map<K, V> ``` ``` inline fun <K, V> IntArray.associate(     transform: (Int) -> Pair<K, V> ): Map<K, V> ``` ``` inline fun <K, V> LongArray.associate(     transform: (Long) -> Pair<K, V> ): Map<K, V> ``` ``` inline fun <K, V> FloatArray.associate(     transform: (Float) -> Pair<K, V> ): Map<K, V> ``` ``` inline fun <K, V> DoubleArray.associate(     transform: (Double) -> Pair<K, V> ): Map<K, V> ``` ``` inline fun <K, V> BooleanArray.associate(     transform: (Boolean) -> Pair<K, V> ): Map<K, V> ``` ``` inline fun <K, V> CharArray.associate(     transform: (Char) -> Pair<K, V> ): Map<K, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](associate#kotlin.collections%24associate(kotlin.Array((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. If any of two pairs would have the same key the last one gets added to the map. The returned map preserves the entry iteration order of the original array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val charCodes = intArrayOf(72, 69, 76, 76, 79) val byCharCode = charCodes.associate { it to Char(it) } // 76=L only occurs once because only the last pair with the same key gets added println(byCharCode) // {72=H, 69=E, 76=L, 79=O} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` Returns a [Map](-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. If any of two pairs would have the same key the last one gets added to the map. The returned map preserves the entry iteration order of the original collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val names = listOf("Grace Hopper", "Jacob Bernoulli", "Johann Bernoulli") val byLastName = names.associate { it.split(" ").let { (firstName, lastName) -> lastName to firstName } } // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace, Bernoulli=Johann} //sampleEnd } ``` kotlin asLongArray asLongArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [asLongArray](as-long-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ULongArray.asLongArray(): LongArray ``` Returns an array of type [LongArray](../kotlin/-long-array/index#kotlin.LongArray), which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array. kotlin toCharArray toCharArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toCharArray](to-char-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Array<out Char>.toCharArray(): CharArray ``` Returns an array of Char containing all of the elements of this generic array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Collection<Char>.toCharArray(): CharArray ``` Returns an array of Char containing all of the elements of this collection. kotlin withIndex withIndex ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [withIndex](with-index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.withIndex(): Iterable<IndexedValue<T>> ``` ``` fun ByteArray.withIndex(): Iterable<IndexedValue<Byte>> ``` ``` fun ShortArray.withIndex(): Iterable<IndexedValue<Short>> ``` ``` fun IntArray.withIndex(): Iterable<IndexedValue<Int>> ``` ``` fun LongArray.withIndex(): Iterable<IndexedValue<Long>> ``` ``` fun FloatArray.withIndex(): Iterable<IndexedValue<Float>> ``` ``` fun DoubleArray.withIndex(): Iterable<IndexedValue<Double>> ``` ``` fun BooleanArray.withIndex(): Iterable<IndexedValue<Boolean>> ``` ``` fun CharArray.withIndex(): Iterable<IndexedValue<Char>> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.withIndex(): Iterable<IndexedValue<UInt>> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.withIndex(): Iterable<IndexedValue<ULong>> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.withIndex(): Iterable<IndexedValue<UByte>> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.withIndex(): Iterable<IndexedValue<UShort>> ``` Returns a lazy [Iterable](-iterable/index#kotlin.collections.Iterable) that wraps each element of the original array into an [IndexedValue](-indexed-value/index) containing the index of that element and the element itself. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` Returns a lazy [Iterable](-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](-indexed-value/index) containing the index of that element and the element itself. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` Returns an [Iterator](-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](-indexed-value/index) containing the index of that element and the element itself. ``` import java.util.* fun main(args: Array<String>) { //sampleStart val iterator = ('a'..'c').iterator() for ((index, value) in iterator.withIndex()) { println("The element at $index is $value") } //sampleEnd } ``` kotlin set set === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> MutableMap<K, V>.set(key: K, value: V) ``` Allows to use the index operator for storing values in a mutable map. kotlin groupByTo groupByTo ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [groupByTo](group-by-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Array<out T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, MutableList<Byte>>> ByteArray.groupByTo(     destination: M,     keySelector: (Byte) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, MutableList<Short>>> ShortArray.groupByTo(     destination: M,     keySelector: (Short) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, MutableList<Int>>> IntArray.groupByTo(     destination: M,     keySelector: (Int) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, MutableList<Long>>> LongArray.groupByTo(     destination: M,     keySelector: (Long) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, MutableList<Float>>> FloatArray.groupByTo(     destination: M,     keySelector: (Float) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, MutableList<Double>>> DoubleArray.groupByTo(     destination: M,     keySelector: (Double) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, MutableList<Boolean>>> BooleanArray.groupByTo(     destination: M,     keySelector: (Boolean) -> K ): M ``` ``` inline fun <K, M : MutableMap<in K, MutableList<Char>>> CharArray.groupByTo(     destination: M,     keySelector: (Char) -> K ): M ``` ``` @ExperimentalUnsignedTypes inline fun <K, M : MutableMap<in K, MutableList<UInt>>> UIntArray.groupByTo(     destination: M,     keySelector: (UInt) -> K ): M ``` ``` @ExperimentalUnsignedTypes inline fun <K, M : MutableMap<in K, MutableList<ULong>>> ULongArray.groupByTo(     destination: M,     keySelector: (ULong) -> K ): M ``` ``` @ExperimentalUnsignedTypes inline fun <K, M : MutableMap<in K, MutableList<UByte>>> UByteArray.groupByTo(     destination: M,     keySelector: (UByte) -> K ): M ``` ``` @ExperimentalUnsignedTypes inline fun <K, M : MutableMap<in K, MutableList<UShort>>> UShortArray.groupByTo(     destination: M,     keySelector: (UShort) -> K ): M ``` Groups elements of the original array by the key returned by the given [keySelector](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val byLength = words.groupBy { it.length } println(byLength.keys) // [1, 3, 2, 4] println(byLength.values) // [[a], [abc, def], [ab], [abcd]] val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } // same content as in byLength map, but the map is mutable println("mutableByLength == byLength is ${mutableByLength == byLength}") // true //sampleEnd } ``` **Return** The [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Array<out T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, MutableList<V>>> ByteArray.groupByTo(     destination: M,     keySelector: (Byte) -> K,     valueTransform: (Byte) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, MutableList<V>>> ShortArray.groupByTo(     destination: M,     keySelector: (Short) -> K,     valueTransform: (Short) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, MutableList<V>>> IntArray.groupByTo(     destination: M,     keySelector: (Int) -> K,     valueTransform: (Int) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, MutableList<V>>> LongArray.groupByTo(     destination: M,     keySelector: (Long) -> K,     valueTransform: (Long) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, MutableList<V>>> FloatArray.groupByTo(     destination: M,     keySelector: (Float) -> K,     valueTransform: (Float) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, MutableList<V>>> DoubleArray.groupByTo(     destination: M,     keySelector: (Double) -> K,     valueTransform: (Double) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, MutableList<V>>> BooleanArray.groupByTo(     destination: M,     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> V ): M ``` ``` inline fun <K, V, M : MutableMap<in K, MutableList<V>>> CharArray.groupByTo(     destination: M,     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): M ``` ``` @ExperimentalUnsignedTypes inline fun <K, V, M : MutableMap<in K, MutableList<V>>> UIntArray.groupByTo(     destination: M,     keySelector: (UInt) -> K,     valueTransform: (UInt) -> V ): M ``` ``` @ExperimentalUnsignedTypes inline fun <K, V, M : MutableMap<in K, MutableList<V>>> ULongArray.groupByTo(     destination: M,     keySelector: (ULong) -> K,     valueTransform: (ULong) -> V ): M ``` ``` @ExperimentalUnsignedTypes inline fun <K, V, M : MutableMap<in K, MutableList<V>>> UByteArray.groupByTo(     destination: M,     keySelector: (UByte) -> K,     valueTransform: (UByte) -> V ): M ``` ``` @ExperimentalUnsignedTypes inline fun <K, V, M : MutableMap<in K, MutableList<V>>> UShortArray.groupByTo(     destination: M,     keySelector: (UShort) -> K,     valueTransform: (UShort) -> V ): M ``` Groups values returned by the [valueTransform](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original array by the key returned by the given [keySelector](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing") val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first }) println(namesByTeam) // {Marketing=[Alice, Carol], Sales=[Bob]} val mutableNamesByTeam = nameToTeam.groupByTo(HashMap(), { it.second }, { it.first }) // same content as in namesByTeam map, but the map is mutable println("mutableNamesByTeam == namesByTeam is ${mutableNamesByTeam == namesByTeam}") // true //sampleEnd } ``` **Return** The [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.Array((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups elements of the original collection by the key returned by the given [keySelector](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val byLength = words.groupBy { it.length } println(byLength.keys) // [1, 3, 2, 4] println(byLength.values) // [[a], [abc, def], [ab], [abcd]] val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } // same content as in byLength map, but the map is mutable println("mutableByLength == byLength is ${mutableByLength == byLength}") // true //sampleEnd } ``` **Return** The [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` Groups values returned by the [valueTransform](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing") val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first }) println(namesByTeam) // {Marketing=[Alice, Carol], Sales=[Bob]} val mutableNamesByTeam = nameToTeam.groupByTo(HashMap(), { it.second }, { it.first }) // same content as in namesByTeam map, but the map is mutable println("mutableNamesByTeam == namesByTeam is ${mutableNamesByTeam == namesByTeam}") // true //sampleEnd } ``` **Return** The [destination](group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map.
programming_docs
kotlin getOrNull getOrNull ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [getOrNull](get-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.getOrNull(index: Int): T? ``` ``` fun ByteArray.getOrNull(index: Int): Byte? ``` ``` fun ShortArray.getOrNull(index: Int): Short? ``` ``` fun IntArray.getOrNull(index: Int): Int? ``` ``` fun LongArray.getOrNull(index: Int): Long? ``` ``` fun FloatArray.getOrNull(index: Int): Float? ``` ``` fun DoubleArray.getOrNull(index: Int): Double? ``` ``` fun BooleanArray.getOrNull(index: Int): Boolean? ``` ``` fun CharArray.getOrNull(index: Int): Char? ``` ``` @ExperimentalUnsignedTypes fun UIntArray.getOrNull(     index: Int ): UInt? ``` ``` @ExperimentalUnsignedTypes fun ULongArray.getOrNull(     index: Int ): ULong? ``` ``` @ExperimentalUnsignedTypes fun UByteArray.getOrNull(     index: Int ): UByte? ``` ``` @ExperimentalUnsignedTypes fun UShortArray.getOrNull(     index: Int ): UShort? ``` Returns an element at the given [index](get-or-null#kotlin.collections%24getOrNull(kotlin.Array((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](get-or-null#kotlin.collections%24getOrNull(kotlin.Array((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.getOrNull(0)) // 1 println(list.getOrNull(2)) // 3 println(list.getOrNull(3)) // null val emptyList = emptyList<Int>() println(emptyList.getOrNull(0)) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.getOrNull(index: Int): T? ``` Returns an element at the given [index](get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.getOrNull(0)) // 1 println(list.getOrNull(2)) // 3 println(list.getOrNull(3)) // null val emptyList = emptyList<Int>() println(emptyList.getOrNull(0)) // null //sampleEnd } ``` kotlin mapKeys mapKeys ======= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapKeys](map-keys) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R> Map<out K, V>.mapKeys(     transform: (Entry<K, V>) -> R ): Map<R, V> ``` Returns a new Map with entries having the keys obtained by applying the [transform](map-keys#kotlin.collections%24mapKeys(kotlin.collections.Map((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.collections.mapKeys.R)))/transform) function to each entry in this [Map](-map/index#kotlin.collections.Map) and the values of this map. In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite the value associated with the former one. The returned map preserves the entry iteration order of the original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val map1 = mapOf("beer" to 2.7, "bisquit" to 5.8) val map2 = map1.mapKeys { it.key.length } println(map2) // {4=2.7, 7=5.8} val map3 = map1.mapKeys { it.key.take(1) } println(map3) // {b=5.8} //sampleEnd } ``` kotlin plus plus ==== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <plus> **Platform and version requirements:** JVM (1.0), Native (1.3) ``` operator fun <T> Array<T>.plus(element: T): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` operator fun <T> Array<out T>.plus(element: T): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ByteArray.plus(element: Byte): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ShortArray.plus(element: Short): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun IntArray.plus(element: Int): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun LongArray.plus(element: Long): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun FloatArray.plus(element: Float): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun DoubleArray.plus(element: Double): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun BooleanArray.plus(     element: Boolean ): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun CharArray.plus(element: Char): CharArray ``` Returns an array containing all elements of the original array and then the given [element](plus#kotlin.collections%24plus(kotlin.Array((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). **Platform and version requirements:** JVM (1.0), Native (1.3) ``` operator fun <T> Array<T>.plus(     elements: Collection<T> ): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` operator fun <T> Array<out T>.plus(     elements: Collection<T> ): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ByteArray.plus(     elements: Collection<Byte> ): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ShortArray.plus(     elements: Collection<Short> ): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun IntArray.plus(     elements: Collection<Int> ): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun LongArray.plus(     elements: Collection<Long> ): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun FloatArray.plus(     elements: Collection<Float> ): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun DoubleArray.plus(     elements: Collection<Double> ): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun BooleanArray.plus(     elements: Collection<Boolean> ): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun CharArray.plus(     elements: Collection<Char> ): CharArray ``` Returns an array containing all elements of the original array and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.Array((kotlin.collections.plus.T)),%20kotlin.collections.Collection((kotlin.collections.plus.T)))/elements) collection. **Platform and version requirements:** JVM (1.0), Native (1.3) ``` operator fun <T> Array<T>.plus(     elements: Array<out T> ): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` operator fun <T> Array<out T>.plus(     elements: Array<out T> ): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ByteArray.plus(elements: ByteArray): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun ShortArray.plus(     elements: ShortArray ): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun IntArray.plus(elements: IntArray): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun LongArray.plus(elements: LongArray): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun FloatArray.plus(     elements: FloatArray ): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun DoubleArray.plus(     elements: DoubleArray ): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun BooleanArray.plus(     elements: BooleanArray ): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` operator fun CharArray.plus(elements: CharArray): CharArray ``` Returns an array containing all elements of the original array and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.Array((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then the given [element](plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.plus(element: T): Set<T> ``` Returns a set containing all elements of the original set and then the given [element](plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element) if it isn't already in this set. The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array, which aren't already in this set. The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection, which aren't already in this set. The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence, which aren't already in this set. The returned set preserves the element iteration order of the original set. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes operator fun UIntArray.plus(     element: UInt ): UIntArray ``` ``` @ExperimentalUnsignedTypes operator fun ULongArray.plus(     element: ULong ): ULongArray ``` ``` @ExperimentalUnsignedTypes operator fun UByteArray.plus(     element: UByte ): UByteArray ``` ``` @ExperimentalUnsignedTypes operator fun UShortArray.plus(     element: UShort ): UShortArray ``` Returns an array containing all elements of the original array and then the given [element](plus#kotlin.collections%24plus(kotlin.UIntArray,%20kotlin.UInt)/element). **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes operator fun UIntArray.plus(     elements: Collection<UInt> ): UIntArray ``` ``` @ExperimentalUnsignedTypes operator fun ULongArray.plus(     elements: Collection<ULong> ): ULongArray ``` ``` @ExperimentalUnsignedTypes operator fun UByteArray.plus(     elements: Collection<UByte> ): UByteArray ``` ``` @ExperimentalUnsignedTypes operator fun UShortArray.plus(     elements: Collection<UShort> ): UShortArray ``` Returns an array containing all elements of the original array and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.UIntArray,%20kotlin.collections.Collection((kotlin.UInt)))/elements) collection. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes operator fun UIntArray.plus(     elements: UIntArray ): UIntArray ``` ``` @ExperimentalUnsignedTypes operator fun ULongArray.plus(     elements: ULongArray ): ULongArray ``` ``` @ExperimentalUnsignedTypes operator fun UByteArray.plus(     elements: UByteArray ): UByteArray ``` ``` @ExperimentalUnsignedTypes operator fun UShortArray.plus(     elements: UShortArray ): UShortArray ``` Returns an array containing all elements of the original array and then all elements of the given [elements](plus#kotlin.collections%24plus(kotlin.UIntArray,%20kotlin.UIntArray)/elements) array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     pair: Pair<K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair). The returned map preserves the entry iteration order of the original map. The [pair](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair) is iterated in the end if it has a unique key. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Iterable<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). The returned map preserves the entry iteration order of the original map. Those [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs) with unique keys are iterated in the end in the order of [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs) collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Array<out Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). The returned map preserves the entry iteration order of the original map. Those [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs) with unique keys are iterated in the end in the order of [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs) array. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Sequence<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). The returned map preserves the entry iteration order of the original map. Those [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs) with unique keys are iterated in the end in the order of [pairs](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs) sequence. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.plus(     map: Map<out K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from another [map](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map). The returned map preserves the entry iteration order of the original map. Those entries of another [map](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map) that are missing in this map are iterated in the end in the order of that [map](plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map).
programming_docs
kotlin mapNotNullTo mapNotNullTo ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapNotNullTo](map-not-null-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any, C : MutableCollection<in R>> Array<out T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` Applies the given [transform](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.Array((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original array and appends only the non-null results to the given [destination](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.Array((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` Applies the given [transform](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(     destination: C,     transform: (Entry<K, V>) -> R? ): C ``` Applies the given [transform](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each entry in the original map and appends only the non-null results to the given [destination](map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/destination). kotlin reduceRightIndexed reduceRightIndexed ================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reduceRightIndexed](reduce-right-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> Array<out T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` ``` inline fun ByteArray.reduceRightIndexed(     operation: (index: Int, Byte, acc: Byte) -> Byte ): Byte ``` ``` inline fun ShortArray.reduceRightIndexed(     operation: (index: Int, Short, acc: Short) -> Short ): Short ``` ``` inline fun IntArray.reduceRightIndexed(     operation: (index: Int, Int, acc: Int) -> Int ): Int ``` ``` inline fun LongArray.reduceRightIndexed(     operation: (index: Int, Long, acc: Long) -> Long ): Long ``` ``` inline fun FloatArray.reduceRightIndexed(     operation: (index: Int, Float, acc: Float) -> Float ): Float ``` ``` inline fun DoubleArray.reduceRightIndexed(     operation: (index: Int, Double, acc: Double) -> Double ): Double ``` ``` inline fun BooleanArray.reduceRightIndexed(     operation: (index: Int, Boolean, acc: Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.reduceRightIndexed(     operation: (index: Int, Char, acc: Char) -> Char ): Char ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.reduceRightIndexed(     operation: (index: Int, UInt, acc: UInt) -> UInt ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.reduceRightIndexed(     operation: (index: Int, ULong, acc: ULong) -> ULong ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.reduceRightIndexed(     operation: (index: Int, UByte, acc: UByte) -> UByte ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.reduceRightIndexed(     operation: (index: Int, UShort, acc: UShort) -> UShort ): UShort ``` Accumulates value starting with the last element and applying [operation](reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.Array((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. Throws an exception if this array is empty. If the array can be empty in an expected way, please use [reduceRightIndexedOrNull](reduce-right-indexed-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRight { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexed { index, string, acc -> acc + string + index }) // dc2b1a0 // emptyList<Int>().reduceRight { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` Accumulates value starting with the last element and applying [operation](reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. Throws an exception if this list is empty. If the list can be empty in an expected way, please use [reduceRightIndexedOrNull](reduce-right-indexed-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRight { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexed { index, string, acc -> acc + string + index }) // dc2b1a0 // emptyList<Int>().reduceRight { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value. kotlin dropLastWhile dropLastWhile ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [dropLastWhile](drop-last-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` inline fun ByteArray.dropLastWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` inline fun ShortArray.dropLastWhile(     predicate: (Short) -> Boolean ): List<Short> ``` ``` inline fun IntArray.dropLastWhile(     predicate: (Int) -> Boolean ): List<Int> ``` ``` inline fun LongArray.dropLastWhile(     predicate: (Long) -> Boolean ): List<Long> ``` ``` inline fun FloatArray.dropLastWhile(     predicate: (Float) -> Boolean ): List<Float> ``` ``` inline fun DoubleArray.dropLastWhile(     predicate: (Double) -> Boolean ): List<Double> ``` ``` inline fun BooleanArray.dropLastWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.dropLastWhile(     predicate: (Char) -> Boolean ): List<Char> ``` ``` inline fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.dropLastWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.dropLastWhile(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.dropLastWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.dropLastWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` Returns a list containing all elements except last elements that satisfy the given [predicate](drop-last-while#kotlin.collections%24dropLastWhile(kotlin.Array((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.drop(23)) // [x, y, z] println(chars.dropLast(23)) // [a, b, c] println(chars.dropWhile { it < 'x' }) // [x, y, z] println(chars.dropLastWhile { it > 'c' }) // [a, b, c] //sampleEnd } ``` kotlin filterNot filterNot ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterNot](filter-not) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` ``` inline fun ByteArray.filterNot(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` inline fun ShortArray.filterNot(     predicate: (Short) -> Boolean ): List<Short> ``` ``` inline fun IntArray.filterNot(     predicate: (Int) -> Boolean ): List<Int> ``` ``` inline fun LongArray.filterNot(     predicate: (Long) -> Boolean ): List<Long> ``` ``` inline fun FloatArray.filterNot(     predicate: (Float) -> Boolean ): List<Float> ``` ``` inline fun DoubleArray.filterNot(     predicate: (Double) -> Boolean ): List<Double> ``` ``` inline fun BooleanArray.filterNot(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.filterNot(     predicate: (Char) -> Boolean ): List<Char> ``` ``` inline fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.filterNot(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.filterNot(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.filterNot(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.filterNot(     predicate: (UShort) -> Boolean ): List<UShort> ``` Returns a list containing all elements not matching the given [predicate](filter-not#kotlin.collections%24filterNot(kotlin.Array((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = numbers.filter { it % 2 == 0 } val notMultiplesOf3 = numbers.filterNot { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.filterNot(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` Returns a new map containing all key-value pairs not matching the given [predicate](filter-not#kotlin.collections%24filterNot(kotlin.collections.Map((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Boolean)))/predicate). The returned map preserves the entry iteration order of the original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val originalMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3) val filteredMap = originalMap.filterNot { it.value < 3 } println(filteredMap) // {key3=3} // original map has not changed println(originalMap) // {key1=1, key2=2, key3=3} val matchAllPredicate: ((Map.Entry<String, Int>)) -> Boolean = { it.value > 0 } val emptyMap = originalMap.filterNot(matchAllPredicate) println(emptyMap) // {} //sampleEnd } ``` kotlin elementAtOrElse elementAtOrElse =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [elementAtOrElse](element-at-or-else) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` ``` inline fun ByteArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Byte ): Byte ``` ``` inline fun ShortArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Short ): Short ``` ``` inline fun IntArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Int ): Int ``` ``` inline fun LongArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Long ): Long ``` ``` inline fun FloatArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Float ): Float ``` ``` inline fun DoubleArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Double ): Double ``` ``` inline fun BooleanArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Boolean ): Boolean ``` ``` inline fun CharArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UInt ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> ULong ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UByte ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UShort ): UShort ``` Returns an element at the given [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.Array((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.Array((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.Array((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrElse(0) { 42 }) // 1 println(list.elementAtOrElse(2) { 42 }) // 3 println(list.elementAtOrElse(3) { 42 }) // 42 val emptyList = emptyList<Int>() println(emptyList.elementAtOrElse(0) { "no int" }) // no int //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrElse(0) { 42 }) // 1 println(list.elementAtOrElse(2) { 42 }) // 3 println(list.elementAtOrElse(3) { 42 }) // 42 val emptyList = emptyList<Int>() println(emptyList.elementAtOrElse(0) { "no int" }) // no int //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrElse(0) { 42 }) // 1 println(list.elementAtOrElse(2) { 42 }) // 3 println(list.elementAtOrElse(3) { 42 }) // 42 val emptyList = emptyList<Int>() println(emptyList.elementAtOrElse(0) { "no int" }) // no int //sampleEnd } ``` kotlin get get === [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <K, V> Map<out K, V>.get(key: K): V? ``` Returns the value corresponding to the given [key](get#kotlin.collections%24get(kotlin.collections.Map((kotlin.collections.get.K,%20kotlin.collections.get.V)),%20kotlin.collections.get.K)/key), or `null` if such a key is not present in the map. kotlin MutableList MutableList =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [MutableList](-mutable-list) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T> MutableList(     size: Int,     init: (index: Int) -> T ): MutableList<T> ``` Creates a new mutable list with the specified [size](-mutable-list#kotlin.collections%24MutableList(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.MutableList.T)))/size), where each element is calculated by calling the specified [init](-mutable-list#kotlin.collections%24MutableList(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.MutableList.T)))/init) function. The function [init](-mutable-list#kotlin.collections%24MutableList(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.MutableList.T)))/init) is called for each list element sequentially starting from the first one. It should return the value for a list element given its index. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = MutableList(3) { index -> 'A' + index } println(list) // [A, B, C] list.clear() println(list) // [] //sampleEnd } ```
programming_docs
kotlin runningReduceIndexed runningReduceIndexed ==================== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [runningReduceIndexed](running-reduce-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Array<out T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.runningReduceIndexed(     operation: (index: Int, acc: UInt, UInt) -> UInt ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.runningReduceIndexed(     operation: (index: Int, acc: ULong, ULong) -> ULong ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.runningReduceIndexed(     operation: (index: Int, acc: UByte, UByte) -> UByte ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.runningReduceIndexed(     operation: (index: Int, acc: UShort, UShort) -> UShort ): List<UShort> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.Array((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with the first element of this array. Note that `acc` value passed to [operation](running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.Array((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun ByteArray.runningReduceIndexed(     operation: (index: Int, acc: Byte, Byte) -> Byte ): List<Byte> ``` ``` inline fun ShortArray.runningReduceIndexed(     operation: (index: Int, acc: Short, Short) -> Short ): List<Short> ``` ``` inline fun IntArray.runningReduceIndexed(     operation: (index: Int, acc: Int, Int) -> Int ): List<Int> ``` ``` inline fun LongArray.runningReduceIndexed(     operation: (index: Int, acc: Long, Long) -> Long ): List<Long> ``` ``` inline fun FloatArray.runningReduceIndexed(     operation: (index: Int, acc: Float, Float) -> Float ): List<Float> ``` ``` inline fun DoubleArray.runningReduceIndexed(     operation: (index: Int, acc: Double, Double) -> Double ): List<Double> ``` ``` inline fun BooleanArray.runningReduceIndexed(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.runningReduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): List<Char> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.ByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Byte,%20,%20)))/operation) from left to right to each element, its index in the original array and current accumulator value that starts with the first element of this array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. Note that `acc` value passed to [operation](running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. kotlin filterNotNull filterNotNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [filterNotNull](filter-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> Array<out T?>.filterNotNull(): List<T> ``` ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` Returns a list containing all elements that are not `null`. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int?> = listOf(1, 2, null, 4) val nonNullNumbers = numbers.filterNotNull() println(nonNullNumbers) // [1, 2, 4] //sampleEnd } ``` kotlin minOfOrNull minOfOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minOfOrNull](min-of-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Array<out T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` inline fun ByteArray.minOfOrNull(     selector: (Byte) -> Double ): Double? ``` ``` inline fun ShortArray.minOfOrNull(     selector: (Short) -> Double ): Double? ``` ``` inline fun IntArray.minOfOrNull(     selector: (Int) -> Double ): Double? ``` ``` inline fun LongArray.minOfOrNull(     selector: (Long) -> Double ): Double? ``` ``` inline fun FloatArray.minOfOrNull(     selector: (Float) -> Double ): Double? ``` ``` inline fun DoubleArray.minOfOrNull(     selector: (Double) -> Double ): Double? ``` ``` inline fun BooleanArray.minOfOrNull(     selector: (Boolean) -> Double ): Double? ``` ``` inline fun CharArray.minOfOrNull(     selector: (Char) -> Double ): Double? ``` ``` inline fun <T> Array<out T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` inline fun ByteArray.minOfOrNull(     selector: (Byte) -> Float ): Float? ``` ``` inline fun ShortArray.minOfOrNull(     selector: (Short) -> Float ): Float? ``` ``` inline fun IntArray.minOfOrNull(     selector: (Int) -> Float ): Float? ``` ``` inline fun LongArray.minOfOrNull(     selector: (Long) -> Float ): Float? ``` ``` inline fun FloatArray.minOfOrNull(     selector: (Float) -> Float ): Float? ``` ``` inline fun DoubleArray.minOfOrNull(     selector: (Double) -> Float ): Float? ``` ``` inline fun BooleanArray.minOfOrNull(     selector: (Boolean) -> Float ): Float? ``` ``` inline fun CharArray.minOfOrNull(     selector: (Char) -> Float ): Float? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.minOfOrNull(     selector: (UInt) -> Double ): Double? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.minOfOrNull(     selector: (ULong) -> Double ): Double? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.minOfOrNull(     selector: (UByte) -> Double ): Double? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.minOfOrNull(     selector: (UShort) -> Double ): Double? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.minOfOrNull(     selector: (UInt) -> Float ): Float? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.minOfOrNull(     selector: (ULong) -> Float ): Float? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.minOfOrNull(     selector: (UByte) -> Float ): Float? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.minOfOrNull(     selector: (UShort) -> Float ): Float? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.Array((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. If any of values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.Array((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Array<out T>.minOfOrNull(     selector: (T) -> R ): R? ``` ``` inline fun <R : Comparable<R>> ByteArray.minOfOrNull(     selector: (Byte) -> R ): R? ``` ``` inline fun <R : Comparable<R>> ShortArray.minOfOrNull(     selector: (Short) -> R ): R? ``` ``` inline fun <R : Comparable<R>> IntArray.minOfOrNull(     selector: (Int) -> R ): R? ``` ``` inline fun <R : Comparable<R>> LongArray.minOfOrNull(     selector: (Long) -> R ): R? ``` ``` inline fun <R : Comparable<R>> FloatArray.minOfOrNull(     selector: (Float) -> R ): R? ``` ``` inline fun <R : Comparable<R>> DoubleArray.minOfOrNull(     selector: (Double) -> R ): R? ``` ``` inline fun <R : Comparable<R>> BooleanArray.minOfOrNull(     selector: (Boolean) -> R ): R? ``` ``` inline fun <R : Comparable<R>> CharArray.minOfOrNull(     selector: (Char) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.minOfOrNull(     selector: (UInt) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.minOfOrNull(     selector: (ULong) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.minOfOrNull(     selector: (UByte) -> R ): R? ``` ``` @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.minOfOrNull(     selector: (UShort) -> R ): R? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.Array((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.collections.minOfOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` inline fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. If any of values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.collections.minOfOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` inline fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. If any of values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, R : Comparable<R>> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.collections.minOfOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. kotlin minusAssign minusAssign =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [minusAssign](minus-assign) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) ``` Removes the entry with the given [key](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.minusAssign.K)/key) from this mutable map. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Iterable<K>) ``` Removes all entries the keys of which are contained in the given [keys](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.K)))/keys) collection from this mutable map. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Array<out K>) ``` Removes all entries the keys of which are contained in the given [keys](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.Array((kotlin.collections.minusAssign.K)))/keys) array from this mutable map. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Sequence<K>) ``` Removes all entries from the keys of which are contained in the given [keys](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.K)))/keys) sequence from this mutable map. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes a single instance of the specified [element](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` Removes all elements contained in the given [elements](minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. kotlin buildList buildList ========= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [buildList](build-list) **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` inline fun <E> buildList(     builderAction: MutableList<E>.() -> Unit ): List<E> ``` Builds a new read-only [List](-list/index#kotlin.collections.List) by populating a [MutableList](-mutable-list/index#kotlin.collections.MutableList) using the given [builderAction](build-list#kotlin.collections%24buildList(kotlin.Function1((kotlin.collections.MutableList((kotlin.collections.buildList.E)),%20kotlin.Unit)))/builderAction) and returning a read-only list with the same elements. The list passed as a receiver to the [builderAction](build-list#kotlin.collections%24buildList(kotlin.Function1((kotlin.collections.MutableList((kotlin.collections.buildList.E)),%20kotlin.Unit)))/builderAction) is valid only inside that function. Using it outside of the function produces an unspecified behavior. The returned list is serializable (JVM). ``` fun main(args: Array<String>) { //sampleStart val x = listOf('b', 'c') val y = buildList() { add('a') addAll(x) add('d') } println(y) // [a, b, c, d] //sampleEnd } ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` inline fun <E> buildList(     capacity: Int,     builderAction: MutableList<E>.() -> Unit ): List<E> ``` Builds a new read-only [List](-list/index#kotlin.collections.List) by populating a [MutableList](-mutable-list/index#kotlin.collections.MutableList) using the given [builderAction](build-list#kotlin.collections%24buildList(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableList((kotlin.collections.buildList.E)),%20kotlin.Unit)))/builderAction) and returning a read-only list with the same elements. The list passed as a receiver to the [builderAction](build-list#kotlin.collections%24buildList(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableList((kotlin.collections.buildList.E)),%20kotlin.Unit)))/builderAction) is valid only inside that function. Using it outside of the function produces an unspecified behavior. The returned list is serializable (JVM). [capacity](build-list#kotlin.collections%24buildList(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableList((kotlin.collections.buildList.E)),%20kotlin.Unit)))/capacity) is used to hint the expected number of elements added in the [builderAction](build-list#kotlin.collections%24buildList(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableList((kotlin.collections.buildList.E)),%20kotlin.Unit)))/builderAction). ``` fun main(args: Array<String>) { //sampleStart val x = listOf('b', 'c') val y = buildList(x.size + 2) { add('a') addAll(x) add('d') } println(y) // [a, b, c, d] //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if the given [capacity](build-list#kotlin.collections%24buildList(kotlin.Int,%20kotlin.Function1((kotlin.collections.MutableList((kotlin.collections.buildList.E)),%20kotlin.Unit)))/capacity) is negative.
programming_docs
kotlin filter filter ====== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <filter> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.filter(     predicate: (T) -> Boolean ): List<T> ``` ``` inline fun ByteArray.filter(     predicate: (Byte) -> Boolean ): List<Byte> ``` ``` inline fun ShortArray.filter(     predicate: (Short) -> Boolean ): List<Short> ``` ``` inline fun IntArray.filter(     predicate: (Int) -> Boolean ): List<Int> ``` ``` inline fun LongArray.filter(     predicate: (Long) -> Boolean ): List<Long> ``` ``` inline fun FloatArray.filter(     predicate: (Float) -> Boolean ): List<Float> ``` ``` inline fun DoubleArray.filter(     predicate: (Double) -> Boolean ): List<Double> ``` ``` inline fun BooleanArray.filter(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` ``` inline fun CharArray.filter(     predicate: (Char) -> Boolean ): List<Char> ``` ``` inline fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.filter(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.filter(     predicate: (ULong) -> Boolean ): List<ULong> ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.filter(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.filter(     predicate: (UShort) -> Boolean ): List<UShort> ``` Returns a list containing only elements matching the given [predicate](filter#kotlin.collections%24filter(kotlin.Array((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = numbers.filter { it % 2 == 0 } val notMultiplesOf3 = numbers.filterNot { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> Map<out K, V>.filter(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` Returns a new map containing all key-value pairs matching the given [predicate](filter#kotlin.collections%24filter(kotlin.collections.Map((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Boolean)))/predicate). The returned map preserves the entry iteration order of the original map. ``` import kotlin.test.* import java.util.* fun main(args: Array<String>) { //sampleStart val originalMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3) val filteredMap = originalMap.filter { it.value < 2 } println(filteredMap) // {key1=1} // original map has not changed println(originalMap) // {key1=1, key2=2, key3=3} val nonMatchingPredicate: ((Map.Entry<String, Int>)) -> Boolean = { it.value == 0 } val emptyMap = originalMap.filter(nonMatchingPredicate) println(emptyMap) // {} //sampleEnd } ``` kotlin associateWithTo associateWithTo =============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [associateWithTo](associate-with-to) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <K, V, M : MutableMap<in K, in V>> Array<out K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` ``` inline fun <V, M : MutableMap<in Byte, in V>> ByteArray.associateWithTo(     destination: M,     valueSelector: (Byte) -> V ): M ``` ``` inline fun <V, M : MutableMap<in Short, in V>> ShortArray.associateWithTo(     destination: M,     valueSelector: (Short) -> V ): M ``` ``` inline fun <V, M : MutableMap<in Int, in V>> IntArray.associateWithTo(     destination: M,     valueSelector: (Int) -> V ): M ``` ``` inline fun <V, M : MutableMap<in Long, in V>> LongArray.associateWithTo(     destination: M,     valueSelector: (Long) -> V ): M ``` ``` inline fun <V, M : MutableMap<in Float, in V>> FloatArray.associateWithTo(     destination: M,     valueSelector: (Float) -> V ): M ``` ``` inline fun <V, M : MutableMap<in Double, in V>> DoubleArray.associateWithTo(     destination: M,     valueSelector: (Double) -> V ): M ``` ``` inline fun <V, M : MutableMap<in Boolean, in V>> BooleanArray.associateWithTo(     destination: M,     valueSelector: (Boolean) -> V ): M ``` ``` inline fun <V, M : MutableMap<in Char, in V>> CharArray.associateWithTo(     destination: M,     valueSelector: (Char) -> V ): M ``` ``` @ExperimentalUnsignedTypes inline fun <V, M : MutableMap<in UInt, in V>> UIntArray.associateWithTo(     destination: M,     valueSelector: (UInt) -> V ): M ``` ``` @ExperimentalUnsignedTypes inline fun <V, M : MutableMap<in ULong, in V>> ULongArray.associateWithTo(     destination: M,     valueSelector: (ULong) -> V ): M ``` ``` @ExperimentalUnsignedTypes inline fun <V, M : MutableMap<in UByte, in V>> UByteArray.associateWithTo(     destination: M,     valueSelector: (UByte) -> V ): M ``` ``` @ExperimentalUnsignedTypes inline fun <V, M : MutableMap<in UShort, in V>> UShortArray.associateWithTo(     destination: M,     valueSelector: (UShort) -> V ): M ``` Populates and returns the [destination](associate-with-to#kotlin.collections%24associateWithTo(kotlin.Array((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given array, where key is the element itself and value is provided by the [valueSelector](associate-with-to#kotlin.collections%24associateWithTo(kotlin.Array((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. If any two elements are equal, the last one overwrites the former value in the map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Jacob", "Bernoulli")) val withLengthOfNames = mutableMapOf<Person, Int>() println("withLengthOfNames.isEmpty() is ${withLengthOfNames.isEmpty()}") // true scientists.associateWithTo(withLengthOfNames) { it.firstName.length + it.lastName.length } println("withLengthOfNames.isNotEmpty() is ${withLengthOfNames.isNotEmpty()}") // true // Jacob Bernoulli only occurs once in the map because only the last pair with the same key gets added println(withLengthOfNames) // {Grace Hopper=11, Jacob Bernoulli=14} //sampleEnd } ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` Populates and returns the [destination](associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. If any two elements are equal, the last one overwrites the former value in the map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Jacob", "Bernoulli")) val withLengthOfNames = mutableMapOf<Person, Int>() println("withLengthOfNames.isEmpty() is ${withLengthOfNames.isEmpty()}") // true scientists.associateWithTo(withLengthOfNames) { it.firstName.length + it.lastName.length } println("withLengthOfNames.isNotEmpty() is ${withLengthOfNames.isNotEmpty()}") // true // Jacob Bernoulli only occurs once in the map because only the last pair with the same key gets added println(withLengthOfNames) // {Grace Hopper=11, Jacob Bernoulli=14} //sampleEnd } ``` kotlin reduceRightOrNull reduceRightOrNull ================= [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [reduceRightOrNull](reduce-right-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Array<out T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` ``` inline fun ByteArray.reduceRightOrNull(     operation: (Byte, acc: Byte) -> Byte ): Byte? ``` ``` inline fun ShortArray.reduceRightOrNull(     operation: (Short, acc: Short) -> Short ): Short? ``` ``` inline fun IntArray.reduceRightOrNull(     operation: (Int, acc: Int) -> Int ): Int? ``` ``` inline fun LongArray.reduceRightOrNull(     operation: (Long, acc: Long) -> Long ): Long? ``` ``` inline fun FloatArray.reduceRightOrNull(     operation: (Float, acc: Float) -> Float ): Float? ``` ``` inline fun DoubleArray.reduceRightOrNull(     operation: (Double, acc: Double) -> Double ): Double? ``` ``` inline fun BooleanArray.reduceRightOrNull(     operation: (Boolean, acc: Boolean) -> Boolean ): Boolean? ``` ``` inline fun CharArray.reduceRightOrNull(     operation: (Char, acc: Char) -> Char ): Char? ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.reduceRightOrNull(     operation: (UInt, acc: UInt) -> UInt ): UInt? ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.reduceRightOrNull(     operation: (ULong, acc: ULong) -> ULong ): ULong? ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.reduceRightOrNull(     operation: (UByte, acc: UByte) -> UByte ): UByte? ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.reduceRightOrNull(     operation: (UShort, acc: UShort) -> UShort ): UShort? ``` Accumulates value starting with the last element and applying [operation](reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.Array((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. Returns `null` if the array is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRightOrNull { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexedOrNull { index, string, acc -> acc + string + index }) // dc2b1a0 println(emptyList<String>().reduceRightOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes an element and current accumulator value, and calculates the next accumulator value. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` Accumulates value starting with the last element and applying [operation](reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.collections.List((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. Returns `null` if the list is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRightOrNull { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexedOrNull { index, string, acc -> acc + string + index }) // dc2b1a0 println(emptyList<String>().reduceRightOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes an element and current accumulator value, and calculates the next accumulator value. kotlin firstNotNullOf firstNotNullOf ============== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [firstNotNullOf](first-not-null-of) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <T, R : Any> Array<out T>.firstNotNullOf(     transform: (T) -> R? ): R ``` Returns the first non-null value produced by [transform](first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.Array((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this array in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` Returns the first non-null value produced by [transform](first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <K, V, R : Any> Map<out K, V>.firstNotNullOf(     transform: (Entry<K, V>) -> R? ): R ``` Returns the first non-null value produced by [transform](first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Map((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to entries of this map in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` kotlin sortedDescending sortedDescending ================ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortedDescending](sorted-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> Array<out T>.sortedDescending(): List<T> ``` ``` fun <T : Comparable<T>> Iterable<T>.sortedDescending(): List<T> ``` ``` @ExperimentalUnsignedTypes fun UIntArray.sortedDescending(): List<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.sortedDescending(): List<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.sortedDescending(): List<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.sortedDescending(): List<UShort> ``` Returns a list of all elements sorted descending according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.sortedDescending(): List<Byte> ``` ``` fun ShortArray.sortedDescending(): List<Short> ``` ``` fun IntArray.sortedDescending(): List<Int> ``` ``` fun LongArray.sortedDescending(): List<Long> ``` ``` fun FloatArray.sortedDescending(): List<Float> ``` ``` fun DoubleArray.sortedDescending(): List<Double> ``` ``` fun CharArray.sortedDescending(): List<Char> ``` Returns a list of all elements sorted descending according to their natural sort order. kotlin sortByDescending sortByDescending ================ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [sortByDescending](sort-by-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Comparable<R>> Array<out T>.sortByDescending(     crossinline selector: (T) -> R?) ``` Sorts elements in the array in-place descending according to natural sort order of the value returned by specified [selector](sort-by-descending#kotlin.collections%24sortByDescending(kotlin.Array((kotlin.collections.sortByDescending.T)),%20kotlin.Function1((kotlin.collections.sortByDescending.T,%20kotlin.collections.sortByDescending.R?)))/selector) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(     crossinline selector: (T) -> R?) ``` Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector](sort-by-descending#kotlin.collections%24sortByDescending(kotlin.collections.MutableList((kotlin.collections.sortByDescending.T)),%20kotlin.Function1((kotlin.collections.sortByDescending.T,%20kotlin.collections.sortByDescending.R?)))/selector) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting.
programming_docs
kotlin first first ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.first(): T ``` ``` fun ByteArray.first(): Byte ``` ``` fun ShortArray.first(): Short ``` ``` fun IntArray.first(): Int ``` ``` fun LongArray.first(): Long ``` ``` fun FloatArray.first(): Float ``` ``` fun DoubleArray.first(): Double ``` ``` fun BooleanArray.first(): Boolean ``` ``` fun CharArray.first(): Char ``` ``` @ExperimentalUnsignedTypes fun UIntArray.first(): UInt ``` ``` @ExperimentalUnsignedTypes fun ULongArray.first(): ULong ``` ``` @ExperimentalUnsignedTypes fun UByteArray.first(): UByte ``` ``` @ExperimentalUnsignedTypes fun UShortArray.first(): UShort ``` Returns the first element. Exceptions ---------- `NoSuchElementException` - if the array is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Array<out T>.first(     predicate: (T) -> Boolean ): T ``` ``` inline fun ByteArray.first(     predicate: (Byte) -> Boolean ): Byte ``` ``` inline fun ShortArray.first(     predicate: (Short) -> Boolean ): Short ``` ``` inline fun IntArray.first(predicate: (Int) -> Boolean): Int ``` ``` inline fun LongArray.first(     predicate: (Long) -> Boolean ): Long ``` ``` inline fun FloatArray.first(     predicate: (Float) -> Boolean ): Float ``` ``` inline fun DoubleArray.first(     predicate: (Double) -> Boolean ): Double ``` ``` inline fun BooleanArray.first(     predicate: (Boolean) -> Boolean ): Boolean ``` ``` inline fun CharArray.first(     predicate: (Char) -> Boolean ): Char ``` ``` inline fun <T> Iterable<T>.first(     predicate: (T) -> Boolean ): T ``` ``` @ExperimentalUnsignedTypes inline fun UIntArray.first(     predicate: (UInt) -> Boolean ): UInt ``` ``` @ExperimentalUnsignedTypes inline fun ULongArray.first(     predicate: (ULong) -> Boolean ): ULong ``` ``` @ExperimentalUnsignedTypes inline fun UByteArray.first(     predicate: (UByte) -> Boolean ): UByte ``` ``` @ExperimentalUnsignedTypes inline fun UShortArray.first(     predicate: (UShort) -> Boolean ): UShort ``` Returns the first element matching the given [predicate](first#kotlin.collections%24first(kotlin.Array((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). Exceptions ---------- `NoSuchElementException` - if no such element is found. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.first(): T ``` Returns the first element. Exceptions ---------- `NoSuchElementException` - if the collection is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> List<T>.first(): T ``` Returns the first element. Exceptions ---------- `NoSuchElementException` - if the list is empty. kotlin mapTo mapTo ===== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [mapTo](map-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, C : MutableCollection<in R>> Array<out T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> ByteArray.mapTo(     destination: C,     transform: (Byte) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> ShortArray.mapTo(     destination: C,     transform: (Short) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> IntArray.mapTo(     destination: C,     transform: (Int) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> LongArray.mapTo(     destination: C,     transform: (Long) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> FloatArray.mapTo(     destination: C,     transform: (Float) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> DoubleArray.mapTo(     destination: C,     transform: (Double) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> BooleanArray.mapTo(     destination: C,     transform: (Boolean) -> R ): C ``` ``` inline fun <R, C : MutableCollection<in R>> CharArray.mapTo(     destination: C,     transform: (Char) -> R ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UIntArray.mapTo(     destination: C,     transform: (UInt) -> R ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> ULongArray.mapTo(     destination: C,     transform: (ULong) -> R ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UByteArray.mapTo(     destination: C,     transform: (UByte) -> R ): C ``` ``` @ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UShortArray.mapTo(     destination: C,     transform: (UShort) -> R ): C ``` Applies the given [transform](map-to#kotlin.collections%24mapTo(kotlin.Array((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original array and appends the results to the given [destination](map-to#kotlin.collections%24mapTo(kotlin.Array((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` Applies the given [transform](map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(     destination: C,     transform: (Entry<K, V>) -> R ): C ``` Applies the given [transform](map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/transform) function to each entry of the original map and appends the results to the given [destination](map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/destination). kotlin zipWithNext zipWithNext =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [zipWithNext](zip-with-next) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list of pairs of each two adjacent elements in this collection. The returned list is empty if this collection contains less than two elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val letters = ('a'..'f').toList() val pairs = letters.zipWithNext() println(letters) // [a, b, c, d, e, f] println(pairs) // [(a, b), (b, c), (c, d), (d, e), (e, f)] //sampleEnd } ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` inline fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. The returned list is empty if this collection contains less than two elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val values = listOf(1, 4, 9, 16, 25, 36) val deltas = values.zipWithNext { a, b -> b - a } println(deltas) // [3, 5, 7, 9, 11] //sampleEnd } ``` kotlin associateTo associateTo =========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [associateTo](associate-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, in V>> Array<out T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> ByteArray.associateTo(     destination: M,     transform: (Byte) -> Pair<K, V> ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> ShortArray.associateTo(     destination: M,     transform: (Short) -> Pair<K, V> ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> IntArray.associateTo(     destination: M,     transform: (Int) -> Pair<K, V> ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> LongArray.associateTo(     destination: M,     transform: (Long) -> Pair<K, V> ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> FloatArray.associateTo(     destination: M,     transform: (Float) -> Pair<K, V> ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> DoubleArray.associateTo(     destination: M,     transform: (Double) -> Pair<K, V> ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> BooleanArray.associateTo(     destination: M,     transform: (Boolean) -> Pair<K, V> ): M ``` ``` inline fun <K, V, M : MutableMap<in K, in V>> CharArray.associateTo(     destination: M,     transform: (Char) -> Pair<K, V> ): M ``` Populates and returns the [destination](associate-to#kotlin.collections%24associateTo(kotlin.Array((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](associate-to#kotlin.collections%24associateTo(kotlin.Array((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. If any of two pairs would have the same key the last one gets added to the map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val charCodes = intArrayOf(72, 69, 76, 76, 79) val byChar = mutableMapOf<Int, Char>() charCodes.associateTo(byChar) { it to Char(it) } // 76=L only occurs once because only the last pair with the same key gets added println(byChar) // {72=H, 69=E, 76=L, 79=O} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` Populates and returns the [destination](associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. If any of two pairs would have the same key the last one gets added to the map. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = mutableMapOf<String, String>() println("byLastName.isEmpty() is ${byLastName.isEmpty()}") // true scientists.associateTo(byLastName) { it.lastName to it.firstName } println("byLastName.isNotEmpty() is ${byLastName.isNotEmpty()}") // true // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace, Bernoulli=Johann} //sampleEnd } ``` kotlin distinct distinct ======== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <distinct> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Array<out T>.distinct(): List<T> ``` Returns a list containing only distinct elements from the given array. Among equal elements of the given array, only the first one will be present in the resulting list. The elements in the resulting list are in the same order as they were in the source array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'A', 'b', 'B', 'A', 'a') println(list.distinct()) // [a, A, b, B] println(list.distinctBy { it.uppercaseChar() }) // [a, b] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.distinct(): List<Byte> ``` ``` fun ShortArray.distinct(): List<Short> ``` ``` fun IntArray.distinct(): List<Int> ``` ``` fun LongArray.distinct(): List<Long> ``` ``` fun FloatArray.distinct(): List<Float> ``` ``` fun DoubleArray.distinct(): List<Double> ``` ``` fun BooleanArray.distinct(): List<Boolean> ``` ``` fun CharArray.distinct(): List<Char> ``` Returns a list containing only distinct elements from the given array. The elements in the resulting list are in the same order as they were in the source array. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'A', 'b', 'B', 'A', 'a') println(list.distinct()) // [a, A, b, B] println(list.distinctBy { it.uppercaseChar() }) // [a, b] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterable<T>.distinct(): List<T> ``` Returns a list containing only distinct elements from the given collection. Among equal elements of the given collection, only the first one will be present in the resulting list. The elements in the resulting list are in the same order as they were in the source collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'A', 'b', 'B', 'A', 'a') println(list.distinct()) // [a, A, b, B] println(list.distinctBy { it.uppercaseChar() }) // [a, b] //sampleEnd } ``` kotlin component4 component4 ========== [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / <component4> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Array<out T>.component4(): T ``` ``` operator fun ByteArray.component4(): Byte ``` ``` operator fun ShortArray.component4(): Short ``` ``` operator fun IntArray.component4(): Int ``` ``` operator fun LongArray.component4(): Long ``` ``` operator fun FloatArray.component4(): Float ``` ``` operator fun DoubleArray.component4(): Double ``` ``` operator fun BooleanArray.component4(): Boolean ``` ``` operator fun CharArray.component4(): Char ``` ``` @ExperimentalUnsignedTypes operator fun UIntArray.component4(): UInt ``` ``` @ExperimentalUnsignedTypes operator fun ULongArray.component4(): ULong ``` ``` @ExperimentalUnsignedTypes operator fun UByteArray.component4(): UByte ``` ``` @ExperimentalUnsignedTypes operator fun UShortArray.component4(): UShort ``` Returns 4th *element* from the array. If the size of this array is less than 4, throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) except in Kotlin/JS where the behavior is unspecified. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> List<T>.component4(): T ``` Returns 4th *element* from the list. Throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the size of this list is less than 4. kotlin toTypedArray toTypedArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.collections](index) / [toTypedArray](to-typed-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun ByteArray.toTypedArray(): Array<Byte> ``` ``` fun ShortArray.toTypedArray(): Array<Short> ``` ``` fun IntArray.toTypedArray(): Array<Int> ``` ``` fun LongArray.toTypedArray(): Array<Long> ``` ``` fun FloatArray.toTypedArray(): Array<Float> ``` ``` fun DoubleArray.toTypedArray(): Array<Double> ``` ``` fun BooleanArray.toTypedArray(): Array<Boolean> ``` ``` fun CharArray.toTypedArray(): Array<Char> ``` Returns a *typed* object array containing all of the elements of this primitive array. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun UIntArray.toTypedArray(): Array<UInt> ``` ``` @ExperimentalUnsignedTypes fun ULongArray.toTypedArray(): Array<ULong> ``` ``` @ExperimentalUnsignedTypes fun UByteArray.toTypedArray(): Array<UByte> ``` ``` @ExperimentalUnsignedTypes fun UShortArray.toTypedArray(): Array<UShort> ``` Returns a *typed* object array containing all of the elements of this primitive array. **Platform and version requirements:** JVM (1.0), Native (1.3) ``` fun <reified T> Collection<T>.toTypedArray(): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> Collection<T>.toTypedArray(): Array<T> ``` Returns a *typed* array containing all of the elements of this collection. Allocates an array of runtime type `T` having its size equal to the size of this collection and populates the array with the elements of this collection. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val collection = listOf(1, 2, 3) val array = collection.toTypedArray() println(array.contentToString()) // [1, 2, 3] //sampleEnd } ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Collection](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract operator fun contains(     element: @UnsafeVariance E ): Boolean ``` Checks if the specified element is contained in this collection. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Collection](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val size: Int ``` Returns the size of the collection. kotlin Collection Collection ========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Collection](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface Collection<out E> : Iterable<E> ``` A generic collection of elements. Methods in this interface support only read-only access to the collection; read/write access is supported through the [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) interface. Parameters ---------- `E` - the type of elements contained in the collection. The collection is covariant in its element type. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> Returns the size of the collection. ``` abstract val size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks if the specified element is contained in this collection. ``` abstract operator fun contains(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) Checks if all elements in the specified collection are contained in this collection. ``` abstract fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Returns `true` if the collection is empty (contains no elements), `false` otherwise. ``` abstract fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns an iterator over the elements of this object. ``` abstract fun iterator(): Iterator<E> ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements in this collection. ``` fun <T> Collection<T>.count(): Int ``` Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns this Collection if it's not `null` and the empty list otherwise. ``` fun <T> Collection<T>?.orEmpty(): Collection<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Collection((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Collection((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Collection((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Collection((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Collection((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../to-mutable-list) Returns a new [MutableList](../-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this collection. ``` fun <T> Collection<T>.toMutableList(): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** Native (1.3) #### [waitForMultipleFutures](../../kotlin.native.concurrent/wait-for-multiple-futures) ``` fun <T> Collection<Future<T>>.waitForMultipleFutures(     millis: Int ): Set<Future<T>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractCollection](../-abstract-collection/index) Provides a skeletal implementation of the read-only [Collection](index#kotlin.collections.Collection) interface. ``` abstract class AbstractCollection<out E> : Collection<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [List](../-list/index) A generic ordered collection of elements. Methods in this interface support only read-only access to the list; read/write access is supported through the [MutableList](../-mutable-list/index#kotlin.collections.MutableList) interface. ``` interface List<out E> : Collection<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MatchGroupCollection](../../kotlin.text/-match-group-collection/index) Represents a collection of captured groups in a single match of a regular expression. ``` interface MatchGroupCollection : Collection<MatchGroup?> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableCollection](../-mutable-collection/index) A generic collection of elements that supports adding and removing elements. ``` interface MutableCollection<E> :      Collection<E>,     MutableIterable<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Set](../-set/index) A generic unordered collection of elements that does not support duplicate elements. Methods in this interface support only read-only access to the set; read/write access is supported through the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface. ``` interface Set<out E> : Collection<E> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UByteArray](../../kotlin/-u-byte-array/index) ``` class UByteArray : Collection<UByte> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UIntArray](../../kotlin/-u-int-array/index) ``` class UIntArray : Collection<UInt> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ULongArray](../../kotlin/-u-long-array/index) ``` class ULongArray : Collection<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UShortArray](../../kotlin/-u-short-array/index) ``` class UShortArray : Collection<UShort> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Collection](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun iterator(): Iterator<E> ``` Returns an iterator over the elements of this object. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Collection](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` Checks if all elements in the specified collection are contained in this collection. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Collection](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun isEmpty(): Boolean ``` Returns `true` if the collection is empty (contains no elements), `false` otherwise. kotlin nextFloat nextFloat ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [FloatIterator](index) / [nextFloat](next-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun nextFloat(): Float ``` Returns the next value in the sequence without boxing. kotlin FloatIterator FloatIterator ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [FloatIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class FloatIterator : Iterator<Float> ``` An iterator over a sequence of values of type `Float`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An iterator over a sequence of values of type `Float`. ``` FloatIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` fun next(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextFloat](next-float) Returns the next value in the sequence without boxing. ``` abstract fun nextFloat(): Float ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [FloatIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` FloatIterator() ``` An iterator over a sequence of values of type `Float`. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [FloatIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun next(): Float ``` kotlin BooleanIterator BooleanIterator =============== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [BooleanIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class BooleanIterator : Iterator<Boolean> ``` An iterator over a sequence of values of type `Boolean`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An iterator over a sequence of values of type `Boolean`. ``` BooleanIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` fun next(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextBoolean](next-boolean) Returns the next value in the sequence without boxing. ``` abstract fun nextBoolean(): Boolean ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin nextBoolean nextBoolean =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [BooleanIterator](index) / [nextBoolean](next-boolean) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun nextBoolean(): Boolean ``` Returns the next value in the sequence without boxing. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [BooleanIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` BooleanIterator() ``` An iterator over a sequence of values of type `Boolean`. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [BooleanIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun next(): Boolean ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / <contains> **Platform and version requirements:** ``` open fun contains(element: @UnsafeVariance E): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / <size> **Platform and version requirements:** ``` abstract val size: Int ``` kotlin AbstractMutableSet AbstractMutableSet ================== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) **Platform and version requirements:** ``` abstract class AbstractMutableSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableSet<E> :      MutableSet<E>,     AbstractSet<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableSet<E> :      AbstractMutableCollection<E>,     MutableSet<E> ``` Provides a skeletal implementation of the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface. Parameters ---------- `E` - the type of elements contained in the set. The set is invariant in its element type. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0) #### [<init>](-init-) Provides a skeletal implementation of the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface. ``` <init>() ``` Properties ---------- **Platform and version requirements:** #### <size> ``` abstract val size: Int ``` Inherited Properties -------------------- **Platform and version requirements:** #### [size](../-abstract-mutable-collection/size) ``` abstract val size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0) #### <add> Adds the specified element to the set. ``` abstract fun add(element: E): Boolean ``` **Platform and version requirements:** #### [addAll](add-all) ``` open fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### <clear> ``` open fun clear() ``` **Platform and version requirements:** #### <contains> ``` open fun contains(element: E): Boolean ``` **Platform and version requirements:** #### [containsAll](contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) #### <equals> Compares this set with another set instance with the unordered structural equality. ``` open fun equals(other: Any?): Boolean ``` **Platform and version requirements:** JS (1.1) #### [hashCode](hash-code) Returns the hash code value for this set. ``` open fun hashCode(): Int ``` **Platform and version requirements:** #### [isEmpty](is-empty) ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** #### <iterator> ``` abstract fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** #### <remove> ``` open fun remove(element: E): Boolean ``` **Platform and version requirements:** #### [removeAll](remove-all) ``` open fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [retainAll](retain-all) ``` open fun retainAll(elements: Collection<E>): Boolean ``` Inherited Functions ------------------- **Platform and version requirements:** #### [contains](../-abstract-mutable-collection/contains) ``` open fun contains(element: E): Boolean ``` **Platform and version requirements:** #### [containsAll](../-abstract-mutable-collection/contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [isEmpty](../-abstract-mutable-collection/is-empty) ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** #### [iterator](../-abstract-mutable-collection/iterator) ``` abstract fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** JS (1.1) #### [toJSON](../-abstract-mutable-collection/to-j-s-o-n) ``` fun toJSON(): Any ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Set<T>.minus(element: T): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Set((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Set<T>.minusElement(element: T): Set<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element) if it isn't already in this set. ``` operator fun <T> Set<T>.plus(element: T): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection, which aren't already in this set. The returned set preserves the element iteration order of the original set. ``` operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Set((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element) if it isn't already in this set. ``` fun <T> Set<T>.plusElement(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- #### [HashSet](../-hash-set/index) The implementation of the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface, backed by a [HashMap](../-hash-map/index#kotlin.collections.HashMap) instance. **Platform and version requirements:** ``` class HashSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` typealias HashSet<E> = HashSet<E> ``` **Platform and version requirements:** JS (1.1) ``` open class HashSet<E> : AbstractMutableSet<E>, MutableSet<E> ```
programming_docs
kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / <add> **Platform and version requirements:** JVM (1.0) ``` abstract fun add(element: E): Boolean ``` Adds the specified element to the set. This method is redeclared as abstract, because it's not implemented in the base class, so it must be always overridden in the concrete mutable collection implementation. **Return** `true` if the element has been added, `false` if the element is already contained in the set. kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / <remove> **Platform and version requirements:** ``` open fun remove(element: E): Boolean ``` kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / [retainAll](retain-all) **Platform and version requirements:** ``` open fun retainAll(elements: Collection<E>): Boolean ``` kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / [hashCode](hash-code) **Platform and version requirements:** JS (1.1) ``` open fun hashCode(): Int ``` Returns the hash code value for this set. kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / <iterator> **Platform and version requirements:** ``` abstract fun iterator(): MutableIterator<E> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1) ``` protected <init>() ``` Provides a skeletal implementation of the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface. Parameters ---------- `E` - the type of elements contained in the set. The set is invariant in its element type. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / [removeAll](remove-all) **Platform and version requirements:** ``` open fun removeAll(elements: Collection<E>): Boolean ``` kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / <equals> **Platform and version requirements:** JS (1.1) ``` open fun equals(other: Any?): Boolean ``` Compares this set with another set instance with the unordered structural equality. **Return** `true`, if [other](equals#kotlin.collections.AbstractMutableSet%24equals(kotlin.Any?)/other) instance is a [Set](../-set/index#kotlin.collections.Set) of the same size, all elements of which are contained in this set. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / <clear> **Platform and version requirements:** ``` open fun clear() ``` kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / [containsAll](contains-all) **Platform and version requirements:** ``` open fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` open fun isEmpty(): Boolean ``` kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableSet](index) / [addAll](add-all) **Platform and version requirements:** ``` open fun addAll(elements: Collection<E>): Boolean ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Set](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun contains(element: @UnsafeVariance E): Boolean ``` Checks if the specified element is contained in this collection. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Set](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val size: Int ``` Returns the size of the collection. kotlin Set Set === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Set](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface Set<out E> : Collection<E> ``` A generic unordered collection of elements that does not support duplicate elements. Methods in this interface support only read-only access to the set; read/write access is supported through the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface. Parameters ---------- `E` - the type of elements contained in the set. The set is covariant in its element type. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> Returns the size of the collection. ``` abstract val size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks if the specified element is contained in this collection. ``` abstract fun contains(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) Checks if all elements in the specified collection are contained in this collection. ``` abstract fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Returns `true` if the collection is empty (contains no elements), `false` otherwise. ``` abstract fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns an iterator over the elements of this object. ``` abstract fun iterator(): Iterator<E> ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a set containing all elements of the original set except the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Set<T>.minus(element: T): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> ``` Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a set containing all elements of the original set except the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Set((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Set<T>.minusElement(element: T): Set<T> ``` Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns this Set if it's not `null` and the empty set otherwise. ``` fun <T> Set<T>?.orEmpty(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a set containing all elements of the original set and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element) if it isn't already in this set. ``` operator fun <T> Set<T>.plus(element: T): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection, which aren't already in this set. The returned set preserves the element iteration order of the original set. ``` operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> ``` Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a set containing all elements of the original set and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Set((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element) if it isn't already in this set. ``` fun <T> Set<T>.plusElement(element: T): Set<T> ``` Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractSet](../-abstract-set/index) Provides a skeletal implementation of the read-only [Set](index#kotlin.collections.Set) interface. ``` abstract class AbstractSet<out E> :      AbstractCollection<E>,     Set<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableSet](../-mutable-set/index) A generic unordered collection of elements that does not support duplicate elements, and supports adding and removing elements. ``` interface MutableSet<E> : Set<E>, MutableCollection<E> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Set](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun iterator(): Iterator<E> ``` Returns an iterator over the elements of this object. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Set](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` Checks if all elements in the specified collection are contained in this collection. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Set](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun isEmpty(): Boolean ``` Returns `true` if the collection is empty (contains no elements), `false` otherwise. kotlin MutableIterable MutableIterable =============== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableIterable](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface MutableIterable<out T> : Iterable<T> ``` Classes that inherit from this interface can be represented as a sequence of elements that can be iterated over and that supports removing elements during iteration. Parameters ---------- `T` - the type of element being iterated over. The mutable iterator is invariant in its element type. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns an iterator over the elements of this sequence that supports removing elements during iteration. ``` abstract fun iterator(): MutableIterator<T> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all elements from this [MutableIterable](index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only elements of this [MutableIterable](index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../to-mutable-list) Returns a new [MutableList](../-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this collection. ``` fun <T> Iterable<T>.toMutableList(): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableCollection](../-mutable-collection/index) A generic collection of elements that supports adding and removing elements. ``` interface MutableCollection<E> :      Collection<E>,     MutableIterable<E> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableIterable](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun iterator(): MutableIterator<T> ``` Returns an iterator over the elements of this sequence that supports removing elements during iteration. kotlin ByteIterator ByteIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ByteIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class ByteIterator : Iterator<Byte> ``` An iterator over a sequence of values of type `Byte`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An iterator over a sequence of values of type `Byte`. ``` ByteIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` fun next(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextByte](next-byte) Returns the next value in the sequence without boxing. ``` abstract fun nextByte(): Byte ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ByteIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ByteIterator() ``` An iterator over a sequence of values of type `Byte`. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ByteIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun next(): Byte ``` kotlin nextByte nextByte ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ByteIterator](index) / [nextByte](next-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun nextByte(): Byte ``` Returns the next value in the sequence without boxing. kotlin toArray toArray ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [toArray](to-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> toArray(array: Array<T>): Array<T> ``` ``` fun toArray(): Array<Any?> ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(element: E): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` var size: Int ``` kotlin removeFirst removeFirst =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [removeFirst](remove-first) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun removeFirst(): E ``` Removes the first element from this deque and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this deque is empty. kotlin last last ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun last(): E ``` Returns the last element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this deque is empty. kotlin ArrayDeque ArrayDeque ========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` class ArrayDeque<E> : AbstractMutableList<E> ``` Resizable-array implementation of the deque data structure. The name deque is short for "double ended queue" and is usually pronounced "deck". The collection provide methods for convenient access to the both ends. It also implements [MutableList](../-mutable-list/index#kotlin.collections.MutableList) interface and supports efficient get/set operations by index. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Constructs an empty deque with specified initialCapacity, or throws [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if initialCapacity is negative. ``` ArrayDeque(initialCapacity: Int) ``` Constructs an empty deque. ``` ArrayDeque() ``` Constructs a deque that contains the same elements as the specified elements collection in the same order. ``` ArrayDeque(elements: Collection<E>) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> ``` var size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <add> Adds the specified element to the end of this list. ``` fun add(element: E): Boolean ``` ``` fun add(index: Int, element: E) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](add-all) ``` fun addAll(elements: Collection<E>): Boolean ``` ``` fun addAll(index: Int, elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addFirst](add-first) Prepends the specified [element](add-first#kotlin.collections.ArrayDeque%24addFirst(kotlin.collections.ArrayDeque.E)/element) to this deque. ``` fun addFirst(element: E) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addLast](add-last) Appends the specified [element](add-last#kotlin.collections.ArrayDeque%24addLast(kotlin.collections.ArrayDeque.E)/element) to this deque. ``` fun addLast(element: E) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <clear> ``` fun clear() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> ``` fun contains(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> Returns the first element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this deque is empty. ``` fun first(): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](first-or-null) Returns the first element, or `null` if this deque is empty. ``` fun firstOrNull(): E? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> ``` fun get(index: Int): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](index-of) ``` fun indexOf(element: E): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) ``` fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> Returns the last element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this deque is empty. ``` fun last(): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](last-index-of) ``` fun lastIndexOf(element: E): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](last-or-null) Returns the last element, or `null` if this deque is empty. ``` fun lastOrNull(): E? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <remove> ``` fun remove(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](remove-all) ``` fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAt](remove-at) ``` fun removeAt(index: Int): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeFirst](remove-first) Removes the first element from this deque and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this deque is empty. ``` fun removeFirst(): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeFirstOrNull](remove-first-or-null) Removes the first element from this deque and returns that removed element, or returns `null` if this deque is empty. ``` fun removeFirstOrNull(): E? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeLast](remove-last) Removes the last element from this deque and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this deque is empty. ``` fun removeLast(): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeLastOrNull](remove-last-or-null) Removes the last element from this deque and returns that removed element, or returns `null` if this deque is empty. ``` fun removeLastOrNull(): E? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](retain-all) ``` fun retainAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> ``` fun set(index: Int, element: E): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toArray](to-array) ``` fun <T> toArray(array: Array<T>): Array<T> ``` ``` fun toArray(): Array<Any?> ``` Inherited Functions ------------------- **Platform and version requirements:** #### [containsAll](../-abstract-mutable-list/contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) #### [equals](../-abstract-mutable-list/equals) Compares this list with another list instance with the ordered structural equality. ``` open fun equals(other: Any?): Boolean ``` **Platform and version requirements:** JS (1.1) #### [hashCode](../-abstract-mutable-list/hash-code) Returns the hash code value for this list. ``` open fun hashCode(): Int ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../last-index) Returns the index of the last item in the list or -1 if the list is empty. ``` val <T> List<T>.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearch](../binary-search) Searches this list or its range for the provided [element](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for an element for which the given [comparison](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearchBy](../binary-search-by) Searches this list or its range for an element having the key returned by the specified [selector](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. ``` fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     selector: (T) -> K? ): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../component1) Returns 1st *element* from the list. ``` operator fun <T> List<T>.component1(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../component2) Returns 2nd *element* from the list. ``` operator fun <T> List<T>.component2(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../component3) Returns 3rd *element* from the list. ``` operator fun <T> List<T>.component3(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../component4) Returns 4th *element* from the list. ``` operator fun <T> List<T>.component4(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../component5) Returns 5th *element* from the list. ``` operator fun <T> List<T>.component5(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](../drop-last) Returns a list containing all elements except last [n](../drop-last#kotlin.collections%24dropLast(kotlin.collections.List((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](../drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](../drop-last-while#kotlin.collections%24dropLastWhile(kotlin.collections.List((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](../fold-right) Accumulates value starting with [initial](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](../fold-right-indexed) Accumulates value starting with [initial](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns an element at the given [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](../get-or-null) Returns an element at the given [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.getOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` ``` fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](../reduce-right) Accumulates value starting with the last element and applying [operation](../reduce-right#kotlin.collections%24reduceRight(kotlin.collections.List((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](../reduce-right-indexed) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](../reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](../reduce-right-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.collections.List((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` Removes the element at the specified [index](../remove#kotlin.collections%24remove(kotlin.collections.MutableList((kotlin.collections.remove.T)),%20kotlin.Int)/index) from this list. In Kotlin one should use the [MutableList.removeAt](../-mutable-list/remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)) function instead. ``` fun <T> MutableList<T>.remove(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` Removes all elements from this [MutableList](../-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableList((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirst](../remove-first) Removes the first element from this mutable list and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeFirst(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirstOrNull](../remove-first-or-null) Removes the first element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeFirstOrNull(): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLast](../remove-last) Removes the last element from this mutable list and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeLast(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLastOrNull](../remove-last-or-null) Removes the last element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeLastOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` Retains only elements of this [MutableList](../-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableList((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffle](../shuffle) Randomly shuffles elements in this list in-place using the specified [random](../shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> MutableList<T>.shuffle(random: Random) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [slice](../slice) Returns a list containing elements at indices in the specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` Returns a list containing elements at specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortBy](../sort-by) Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector](../sort-by#kotlin.collections%24sortBy(kotlin.collections.MutableList((kotlin.collections.sortBy.T)),%20kotlin.Function1((kotlin.collections.sortBy.T,%20kotlin.collections.sortBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortBy(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortByDescending](../sort-by-descending) Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector](../sort-by-descending#kotlin.collections%24sortByDescending(kotlin.collections.MutableList((kotlin.collections.sortByDescending.T)),%20kotlin.Function1((kotlin.collections.sortByDescending.T,%20kotlin.collections.sortByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](../take-last) Returns a list containing last [n](../take-last#kotlin.collections%24takeLast(kotlin.collections.List((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](../take-last-while) Returns a list containing last elements satisfying the given [predicate](../take-last-while#kotlin.collections%24takeLastWhile(kotlin.collections.List((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ```
programming_docs
kotlin lastOrNull lastOrNull ========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [lastOrNull](last-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun lastOrNull(): E? ``` Returns the last element, or `null` if this deque is empty. kotlin addFirst addFirst ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [addFirst](add-first) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun addFirst(element: E) ``` Prepends the specified [element](add-first#kotlin.collections.ArrayDeque%24addFirst(kotlin.collections.ArrayDeque.E)/element) to this deque. kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <add> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun add(element: E): Boolean ``` Adds the specified element to the end of this list. **Return** `true` because the list is always modified as the result of this operation. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun add(index: Int, element: E) ``` kotlin lastIndexOf lastIndexOf =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [lastIndexOf](last-index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun lastIndexOf(element: E): Int ``` kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <remove> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun remove(element: E): Boolean ``` kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [retainAll](retain-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun retainAll(elements: Collection<E>): Boolean ``` kotlin firstOrNull firstOrNull =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [firstOrNull](first-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun firstOrNull(): E? ``` Returns the first element, or `null` if this deque is empty. kotlin removeAt removeAt ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [removeAt](remove-at) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun removeAt(index: Int): E ``` kotlin removeFirstOrNull removeFirstOrNull ================= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [removeFirstOrNull](remove-first-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun removeFirstOrNull(): E? ``` Removes the first element from this deque and returns that removed element, or returns `null` if this deque is empty. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ArrayDeque(initialCapacity: Int) ``` Constructs an empty deque with specified initialCapacity, or throws [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if initialCapacity is negative. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ArrayDeque() ``` Constructs an empty deque. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ArrayDeque(elements: Collection<E>) ``` Constructs a deque that contains the same elements as the specified elements collection in the same order. kotlin removeLast removeLast ========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [removeLast](remove-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun removeLast(): E ``` Removes the last element from this deque and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this deque is empty. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [removeAll](remove-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun removeAll(elements: Collection<E>): Boolean ``` kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <clear> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun clear() ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isEmpty(): Boolean ``` kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [addAll](add-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun addAll(elements: Collection<E>): Boolean ``` ``` fun addAll(index: Int, elements: Collection<E>): Boolean ``` kotlin removeLastOrNull removeLastOrNull ================ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [removeLastOrNull](remove-last-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun removeLastOrNull(): E? ``` Removes the last element from this deque and returns that removed element, or returns `null` if this deque is empty. kotlin indexOf indexOf ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [indexOf](index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun indexOf(element: E): Int ``` kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun set(index: Int, element: E): E ``` kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun get(index: Int): E ``` kotlin first first ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun first(): E ``` Returns the first element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this deque is empty. kotlin addLast addLast ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayDeque](index) / [addLast](add-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun addLast(element: E) ``` Appends the specified [element](add-last#kotlin.collections.ArrayDeque%24addLast(kotlin.collections.ArrayDeque.E)/element) to this deque. kotlin DoubleIterator DoubleIterator ============== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [DoubleIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class DoubleIterator : Iterator<Double> ``` An iterator over a sequence of values of type `Double`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An iterator over a sequence of values of type `Double`. ``` DoubleIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` fun next(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextDouble](next-double) Returns the next value in the sequence without boxing. ``` abstract fun nextDouble(): Double ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [DoubleIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` DoubleIterator() ``` An iterator over a sequence of values of type `Double`. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [DoubleIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun next(): Double ``` kotlin nextDouble nextDouble ========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [DoubleIterator](index) / [nextDouble](next-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun nextDouble(): Double ``` Returns the next value in the sequence without boxing. kotlin values values ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableMap](index) / <values> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val values: MutableCollection<V> ``` Returns a [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) of all values in this map. Note that this collection may contain duplicate values. kotlin MutableMap MutableMap ========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableMap](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface MutableMap<K, V> : Map<K, V> ``` A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving the value corresponding to each key. Map keys are unique; the map holds only one value for each key. Parameters ---------- `K` - the type of map keys. The map is invariant in its key type. `V` - the type of map values. The mutable map is invariant in its value type. Types ----- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableEntry](-mutable-entry/index) Represents a key/value pair held by a [MutableMap](index#kotlin.collections.MutableMap). ``` interface MutableEntry<K, V> : Entry<K, V> ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <entries> Returns a [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) of all key/value pairs in this map. ``` abstract val entries: MutableSet<MutableEntry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <keys> Returns a [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) of all keys in this map. ``` abstract val keys: MutableSet<K> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <values> Returns a [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) of all values in this map. Note that this collection may contain duplicate values. ``` abstract val values: MutableCollection<V> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <clear> Removes all elements from this map. ``` abstract fun clear() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <put> Associates the specified [value](put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/value) with the specified [key](put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/key) in the map. ``` abstract fun put(key: K, value: V): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [putAll](put-all) Updates this map with key/value pairs from the specified map [from](put-all#kotlin.collections.MutableMap%24putAll(kotlin.collections.Map((kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)))/from). ``` abstract fun putAll(from: Map<out K, V>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <remove> Removes the specified key and its corresponding value from this map. ``` abstract fun remove(key: K): V? ``` Removes the entry for the specified key only if it is mapped to the specified value. ``` open fun remove(key: K, value: V): Boolean ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all entries match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Map((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.all(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if map has at least one entry. ``` fun <K, V> Map<out K, V>.any(): Boolean ``` Returns `true` if at least one entry matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Map((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.any(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Creates an [Iterable](../-iterable/index#kotlin.collections.Iterable) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Checks if the map contains the given key. ``` operator fun <K, V> Map<out K, V>.contains(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](../contains-key) Returns `true` if the map contains the specified [key](../contains-key#kotlin.collections%24containsKey(kotlin.collections.Map((kotlin.collections.containsKey.K,%20kotlin.Any?)),%20kotlin.collections.containsKey.K)/key). ``` fun <K> Map<out K, *>.containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](../contains-value) Returns `true` if the map maps one or more keys to the specified [value](../contains-value#kotlin.collections%24containsValue(kotlin.collections.Map((kotlin.collections.containsValue.K,%20kotlin.collections.containsValue.V)),%20kotlin.collections.containsValue.V)/value). ``` fun <K, V> Map<K, V>.containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of entries in this map. ``` fun <K, V> Map<out K, V>.count(): Int ``` Returns the number of entries matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Map((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.count(     predicate: (Entry<K, V>) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a new map containing all key-value pairs matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Map((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filter(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterKeys](../filter-keys) Returns a map containing all key-value pairs with keys matching the given [predicate](../filter-keys#kotlin.collections%24filterKeys(kotlin.collections.Map((kotlin.collections.filterKeys.K,%20kotlin.collections.filterKeys.V)),%20kotlin.Function1((kotlin.collections.filterKeys.K,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterKeys(     predicate: (K) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a new map containing all key-value pairs not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Map((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterNot(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all entries not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/predicate) into the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/destination). ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all entries matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/predicate) into the mutable map given as [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/destination) parameter. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterValues](../filter-values) Returns a map containing all key-value pairs with values matching the given [predicate](../filter-values#kotlin.collections%24filterValues(kotlin.collections.Map((kotlin.collections.filterValues.K,%20kotlin.collections.filterValues.V)),%20kotlin.Function1((kotlin.collections.filterValues.V,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterValues(     predicate: (V) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Map((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to entries of this map in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOf(     transform: (Entry<K, V>) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Map((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to entries of this map in iteration order, or `null` if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOfOrNull(     transform: (Entry<K, V>) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Iterable<R> ): List<R> ``` ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each entry of original map, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Iterable<R> ): C ``` ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Map((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Unit)))/action) on each entry. ``` fun <K, V> Map<out K, V>.forEach(     action: (Entry<K, V>) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [get](../get) Returns the value corresponding to the given [key](../get#kotlin.collections%24get(kotlin.collections.Map((kotlin.collections.get.K,%20kotlin.collections.get.V)),%20kotlin.collections.get.K)/key), or `null` if such a key is not present in the map. ``` operator fun <K, V> Map<out K, V>.get(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns the value for the given [key](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/key) if the value is present and not `null`. Otherwise, returns the result of the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/defaultValue) function. ``` fun <K, V> Map<K, V>.getOrElse(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrPut](../get-or-put) Returns the value for the given [key](../get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/key) if the value is present and not `null`. Otherwise, calls the [defaultValue](../get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/defaultValue) function, puts its result into the map under the given key and returns the call result. ``` fun <K, V> MutableMap<K, V>.getOrPut(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getValue](../get-value) Returns the value of the property for the given object from this mutable map. ``` operator fun <V, V1 : V> MutableMap<in String, out V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V1 ``` Returns the value for the given [key](../get-value#kotlin.collections%24getValue(kotlin.collections.Map((kotlin.collections.getValue.K,%20kotlin.collections.getValue.V)),%20kotlin.collections.getValue.K)/key) or throws an exception if there is no such key in the map. ``` fun <K, V> Map<K, V>.getValue(key: K): V ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this map if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.M,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the map is empty. ``` fun <M, R> M.ifEmpty(     defaultValue: () -> R ): R where M : Map<*, *>, M : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if this map is not empty. ``` fun <K, V> Map<out K, V>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable map is either null or empty. ``` fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns a [MutableIterator](../-mutable-iterator/index#kotlin.collections.MutableIterator) over the mutable entries in the [MutableMap](index#kotlin.collections.MutableMap). ``` operator fun <K, V> MutableMap<K, V>.iterator(): MutableIterator<MutableEntry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Map((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.collections.map.R)))/transform) function to each entry in the original map. ``` fun <K, V, R> Map<out K, V>.map(     transform: (Entry<K, V>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeys](../map-keys) Returns a new Map with entries having the keys obtained by applying the [transform](../map-keys#kotlin.collections%24mapKeys(kotlin.collections.Map((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.collections.mapKeys.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R> Map<out K, V>.mapKeys(     transform: (Entry<K, V>) -> R ): Map<R, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeysTo](../map-keys-to) Populates the given [destination](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/destination) map with entries having the keys obtained by applying the [transform](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Map((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.collections.mapNotNull.R?)))/transform) function to each entry in the original map. ``` fun <K, V, R : Any> Map<out K, V>.mapNotNull(     transform: (Entry<K, V>) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each entry in the original map and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(     destination: C,     transform: (Entry<K, V>) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/transform) function to each entry of the original map and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(     destination: C,     transform: (Entry<K, V>) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValues](../map-values) Returns a new map with entries having the keys of this map and the values obtained by applying the [transform](../map-values#kotlin.collections%24mapValues(kotlin.collections.Map((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.collections.mapValues.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R> Map<out K, V>.mapValues(     transform: (Entry<K, V>) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValuesTo](../map-values-to) Populates the given [destination](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/destination) map with entries having the keys of this map and the values obtained by applying the [transform](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first entry yielding the largest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.maxOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first entry having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Map((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first entry having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Map((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.minOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minus](../minus) Returns a map containing all entries of the original map except the entry with the given [key](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.minus.K)/key). ``` operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.Iterable((kotlin.collections.minus.K)))/keys) collection. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Iterable<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.Array((kotlin.collections.minus.K)))/keys) array. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Array<out K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.sequences.Sequence((kotlin.collections.minus.K)))/keys) sequence. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Sequence<K> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minusAssign](../minus-assign) Removes the entry with the given [key](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.minusAssign.K)/key) from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) ``` Removes all entries the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.K)))/keys) collection from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Iterable<K>) ``` Removes all entries the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.Array((kotlin.collections.minusAssign.K)))/keys) array from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Array<out K>) ``` Removes all entries from the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.K)))/keys) sequence from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Sequence<K>) ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first entry having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Map((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first entry having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Map((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the map has no entries. ``` fun <K, V> Map<out K, V>.none(): Boolean ``` Returns `true` if no entries match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Map((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.none(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.onEach.K,%20kotlin.collections.onEach.V)),%20kotlin.Unit)))/action) on each entry and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEach(     action: (Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.M,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.Map.Entry((kotlin.collections.onEachIndexed.K,%20kotlin.collections.onEachIndexed.V)),%20kotlin.Unit)))/action) on each entry, providing sequential index with the entry, and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEachIndexed(     action: (index: Int, Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns the [Map](../-map/index#kotlin.collections.Map) if its not `null`, or the empty [Map](../-map/index#kotlin.collections.Map) otherwise. ``` fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair). ``` operator fun <K, V> Map<out K, V>.plus(     pair: Pair<K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Iterable<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Array<out Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Sequence<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from another [map](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map). ``` operator fun <K, V> Map<out K, V>.plus(     map: Map<out K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Appends or replaces the given [pair](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/pair) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pair: Pair<K, V>) ``` Appends or replaces all pairs from the given collection of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Iterable<Pair<K, V>>) ``` Appends or replaces all pairs from the given array of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Array<out Pair<K, V>>) ``` Appends or replaces all pairs from the given sequence of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Sequence<Pair<K, V>>) ``` Appends or replaces all entries from the given [map](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Map((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/map) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     map: Map<K, V>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [putAll](../put-all) Puts all the given [pairs](../put-all#kotlin.collections%24putAll(kotlin.collections.MutableMap((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)))))/pairs) into this [MutableMap](index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Array<out Pair<K, V>>) ``` Puts all the elements of the given collection into this [MutableMap](index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Iterable<Pair<K, V>>) ``` Puts all the elements of the given sequence into this [MutableMap](index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Sequence<Pair<K, V>>) ``` #### [remove](../remove) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Removes the specified key and its corresponding value from this map. ``` fun <K, V> MutableMap<out K, V>.remove(key: K): V? ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2) Removes the entry for the specified key only if it is currently mapped to the specified value. ``` fun <K, V> MutableMap<out K, out V>.remove(     key: K,     value: V ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [set](../set) Allows to use the index operator for storing values in a mutable map. ``` operator fun <K, V> MutableMap<K, V>.set(key: K, value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [setValue](../set-value) Stores the value of the property for the given object in this mutable map. ``` operator fun <V> MutableMap<in String, in V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all key-value pairs. ``` fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMap](../to-map) Returns a new read-only map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Map((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given map. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMutableMap](../to-mutable-map) Returns a new mutable map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0) #### [toProperties](../to-properties) Converts this [Map](../-map/index#kotlin.collections.Map) to a [Properties](https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html) object. ``` fun Map<String, String>.toProperties(): Properties ``` **Platform and version requirements:** JVM (1.0) #### [toSortedMap](../to-sorted-map) Converts this [Map](../-map/index#kotlin.collections.Map) to a [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to the sorting order provided by the given [comparator](../to-sorted-map#kotlin.collections%24toSortedMap(kotlin.collections.Map((kotlin.collections.toSortedMap.K,%20kotlin.collections.toSortedMap.V)),%20java.util.Comparator((kotlin.collections.toSortedMap.K)))/comparator). ``` fun <K, V> Map<out K, V>.toSortedMap(     comparator: Comparator<in K> ): SortedMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withDefault](../with-default) Returns a wrapper of this mutable map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.MutableMap((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> MutableMap<K, V>.withDefault(     defaultValue: (key: K) -> V ): MutableMap<K, V> ``` Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.Map((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> Map<K, V>.withDefault(     defaultValue: (key: K) -> V ): Map<K, V> ``` Inheritors ---------- #### [AbstractMutableMap](../-abstract-mutable-map/index) Provides a skeletal implementation of the [MutableMap](index#kotlin.collections.MutableMap) interface. **Platform and version requirements:** ``` abstract class AbstractMutableMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableMap<K, V> :      MutableMap<K, V>,     AbstractMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableMap<K, V> :      AbstractMap<K, V>,     MutableMap<K, V> ``` #### [HashMap](../-hash-map/index) Hash table based implementation of the [MutableMap](index#kotlin.collections.MutableMap) interface. **Platform and version requirements:** ``` class HashMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` typealias HashMap<K, V> = HashMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` open class HashMap<K, V> :      AbstractMutableMap<K, V>,     MutableMap<K, V> ``` #### [LinkedHashMap](../-linked-hash-map/index) Hash table based implementation of the [MutableMap](index#kotlin.collections.MutableMap) interface, which additionally preserves the insertion order of entries during the iteration. **Platform and version requirements:** ``` class LinkedHashMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` typealias LinkedHashMap<K, V> = LinkedHashMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` open class LinkedHashMap<K, V> :      HashMap<K, V>,     MutableMap<K, V> ```
programming_docs
kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableMap](index) / <remove> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun remove(key: K): V? ``` Removes the specified key and its corresponding value from this map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` open fun remove(key: K, value: V): Boolean ``` Removes the entry for the specified key only if it is mapped to the specified value. **Return** true if entry was removed kotlin keys keys ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableMap](index) / <keys> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val keys: MutableSet<K> ``` Returns a [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) of all keys in this map. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableMap](index) / <clear> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun clear() ``` Removes all elements from this map. kotlin entries entries ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableMap](index) / <entries> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val entries: MutableSet<MutableEntry<K, V>> ``` Returns a [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) of all key/value pairs in this map. kotlin put put === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableMap](index) / <put> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun put(key: K, value: V): V? ``` Associates the specified [value](put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/value) with the specified [key](put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/key) in the map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. kotlin putAll putAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableMap](index) / [putAll](put-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun putAll(from: Map<out K, V>) ``` Updates this map with key/value pairs from the specified map [from](put-all#kotlin.collections.MutableMap%24putAll(kotlin.collections.Map((kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)))/from). kotlin MutableEntry MutableEntry ============ [kotlin-stdlib](../../../../../../../index) / [kotlin.collections](../../index) / [MutableMap](../index) / [MutableEntry](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface MutableEntry<K, V> : Entry<K, V> ``` Represents a key/value pair held by a [MutableMap](../index#kotlin.collections.MutableMap). Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [setValue](set-value) Changes the value associated with the key of this entry. ``` abstract fun setValue(newValue: V): V ``` kotlin setValue setValue ======== [kotlin-stdlib](../../../../../../../index) / [kotlin.collections](../../index) / [MutableMap](../index) / [MutableEntry](index) / [setValue](set-value) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun setValue(newValue: V): V ``` Changes the value associated with the key of this entry. **Return** the previous value corresponding to the key. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / <contains> **Platform and version requirements:** ``` open fun contains(element: @UnsafeVariance E): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / <size> **Platform and version requirements:** ``` abstract val size: Int ``` kotlin AbstractMutableCollection AbstractMutableCollection ========================= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) **Platform and version requirements:** ``` abstract class AbstractMutableCollection<E> :      MutableCollection<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableCollection<E> :      MutableCollection<E>,     AbstractCollection<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableCollection<E> :      AbstractCollection<E>,     MutableCollection<E> ``` Provides a skeletal implementation of the [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) interface. Parameters ---------- `E` - the type of elements contained in the collection. The collection is invariant in its element type. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0) #### [<init>](-init-) Provides a skeletal implementation of the [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) interface. ``` <init>() ``` Properties ---------- **Platform and version requirements:** #### <size> ``` abstract val size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0) #### <add> Adds the specified element to the collection. ``` abstract fun add(element: E): Boolean ``` **Platform and version requirements:** JS (1.0) #### [addAll](add-all) Adds all of the elements of the specified collection to this collection. ``` open fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.0) #### <clear> Removes all elements from this collection. ``` open fun clear() ``` **Platform and version requirements:** #### <contains> ``` open fun contains(element: E): Boolean ``` **Platform and version requirements:** #### [containsAll](contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [isEmpty](is-empty) ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** #### <iterator> ``` abstract fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** JS (1.0) #### <remove> Removes a single instance of the specified element from this collection, if it is present. ``` open fun remove(element: E): Boolean ``` **Platform and version requirements:** JS (1.0) #### [removeAll](remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` open fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.0) #### [retainAll](retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` open fun retainAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) #### [toJSON](to-j-s-o-n) ``` fun toJSON(): Any ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns this Collection if it's not `null` and the empty list otherwise. ``` fun <T> Collection<T>?.orEmpty(): Collection<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- #### [AbstractMutableList](../-abstract-mutable-list/index) Provides a skeletal implementation of the [MutableList](../-mutable-list/index#kotlin.collections.MutableList) interface. **Platform and version requirements:** ``` abstract class AbstractMutableList<E> : MutableList<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableList<E> :      MutableList<E>,     AbstractList<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableList<E> :      AbstractMutableCollection<E>,     MutableList<E> ``` #### [AbstractMutableSet](../-abstract-mutable-set/index) Provides a skeletal implementation of the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface. **Platform and version requirements:** ``` abstract class AbstractMutableSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableSet<E> :      MutableSet<E>,     AbstractSet<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableSet<E> :      AbstractMutableCollection<E>,     MutableSet<E> ```
programming_docs
kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / <add> **Platform and version requirements:** JVM (1.0), JS (1.1) ``` abstract fun add(element: E): Boolean ``` ##### For JVM Adds the specified element to the collection. This method is redeclared as abstract, because it's not implemented in the base class, so it must be always overridden in the concrete mutable collection implementation. **Return** `true` if the element has been added, `false` if the collection does not support duplicates and the element is already contained in the collection. ##### For JS Adds the specified element to the collection. **Return** `true` if the element has been added, `false` if the collection does not support duplicates and the element is already contained in the collection. kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / <remove> **Platform and version requirements:** JS (1.1) ``` open fun remove(element: E): Boolean ``` Removes a single instance of the specified element from this collection, if it is present. **Return** `true` if the element has been successfully removed; `false` if it was not present in the collection. kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / [retainAll](retain-all) **Platform and version requirements:** JS (1.1) ``` open fun retainAll(elements: Collection<E>): Boolean ``` Retains only the elements in this collection that are contained in the specified collection. **Return** `true` if any element was removed from the collection, `false` if the collection was not modified. kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / <iterator> **Platform and version requirements:** ``` abstract fun iterator(): MutableIterator<E> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1) ``` protected <init>() ``` Provides a skeletal implementation of the [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) interface. Parameters ---------- `E` - the type of elements contained in the collection. The collection is invariant in its element type. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / [removeAll](remove-all) **Platform and version requirements:** JS (1.1) ``` open fun removeAll(elements: Collection<E>): Boolean ``` Removes all of this collection's elements that are also contained in the specified collection. **Return** `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified. kotlin toJSON toJSON ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / [toJSON](to-j-s-o-n) **Platform and version requirements:** JS (1.1) ``` protected fun toJSON(): Any ``` **Deprecated:** Provided so that subclasses inherit this function kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / <clear> **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` Removes all elements from this collection. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / [containsAll](contains-all) **Platform and version requirements:** ``` open fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` open fun isEmpty(): Boolean ``` kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableCollection](index) / [addAll](add-all) **Platform and version requirements:** JS (1.1) ``` open fun addAll(elements: Collection<E>): Boolean ``` Adds all of the elements of the specified collection to this collection. **Return** `true` if any of the specified elements was added to the collection, `false` if the collection was not modified. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / <size> **Platform and version requirements:** ``` open val size: Int ``` kotlin values values ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / <values> **Platform and version requirements:** JS (1.1) ``` open val values: MutableCollection<V> ``` Returns a [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) of all values in this map. Note that this collection may contain duplicate values. kotlin AbstractMutableMap AbstractMutableMap ================== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) **Platform and version requirements:** ``` abstract class AbstractMutableMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableMap<K, V> :      MutableMap<K, V>,     AbstractMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableMap<K, V> :      AbstractMap<K, V>,     MutableMap<K, V> ``` Provides a skeletal implementation of the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface. The implementor is required to implement <entries> property, which should return mutable set of map entries, and [put](put#kotlin.collections.AbstractMutableMap%24put(kotlin.collections.AbstractMutableMap.K,%20kotlin.collections.AbstractMutableMap.V)) function. Parameters ---------- `K` - the type of map keys. The map is invariant in its key type. `V` - the type of map values. The map is invariant in its value type. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0) #### [<init>](-init-) Provides a skeletal implementation of the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface. ``` <init>() ``` Properties ---------- **Platform and version requirements:** #### <entries> ``` abstract val entries: MutableSet<MutableEntry<K, V>> ``` **Platform and version requirements:** JS (1.0) #### <keys> Returns a [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) of all keys in this map. ``` open val keys: MutableSet<K> ``` **Platform and version requirements:** #### <size> ``` open val size: Int ``` **Platform and version requirements:** JS (1.0) #### <values> Returns a [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) of all values in this map. Note that this collection may contain duplicate values. ``` open val values: MutableCollection<V> ``` Functions --------- **Platform and version requirements:** JS (1.0) #### <clear> Removes all elements from this map. ``` open fun clear() ``` **Platform and version requirements:** #### [containsKey](contains-key) ``` open fun containsKey(key: K): Boolean ``` **Platform and version requirements:** #### [containsValue](contains-value) ``` open fun containsValue(value: V): Boolean ``` **Platform and version requirements:** #### <get> ``` open fun get(key: K): V? ``` **Platform and version requirements:** #### [isEmpty](is-empty) ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### <put> Associates the specified [value](put#kotlin.collections.AbstractMutableMap%24put(kotlin.collections.AbstractMutableMap.K,%20kotlin.collections.AbstractMutableMap.V)/value) with the specified [key](put#kotlin.collections.AbstractMutableMap%24put(kotlin.collections.AbstractMutableMap.K,%20kotlin.collections.AbstractMutableMap.V)/key) in the map. ``` abstract fun put(key: K, value: V): V? ``` **Platform and version requirements:** JS (1.0) #### [putAll](put-all) Updates this map with key/value pairs from the specified map [from](../-mutable-map/put-all#kotlin.collections.MutableMap%24putAll(kotlin.collections.Map((kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)))/from). ``` open fun putAll(from: Map<out K, V>) ``` **Platform and version requirements:** JS (1.0) #### <remove> Removes the specified key and its corresponding value from this map. ``` open fun remove(key: K): V? ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all entries match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Map((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.all(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if map has at least one entry. ``` fun <K, V> Map<out K, V>.any(): Boolean ``` Returns `true` if at least one entry matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Map((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.any(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Creates an [Iterable](../-iterable/index#kotlin.collections.Iterable) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Checks if the map contains the given key. ``` operator fun <K, V> Map<out K, V>.contains(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](../contains-key) Returns `true` if the map contains the specified [key](../contains-key#kotlin.collections%24containsKey(kotlin.collections.Map((kotlin.collections.containsKey.K,%20kotlin.Any?)),%20kotlin.collections.containsKey.K)/key). ``` fun <K> Map<out K, *>.containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](../contains-value) Returns `true` if the map maps one or more keys to the specified [value](../contains-value#kotlin.collections%24containsValue(kotlin.collections.Map((kotlin.collections.containsValue.K,%20kotlin.collections.containsValue.V)),%20kotlin.collections.containsValue.V)/value). ``` fun <K, V> Map<K, V>.containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of entries in this map. ``` fun <K, V> Map<out K, V>.count(): Int ``` Returns the number of entries matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Map((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.count(     predicate: (Entry<K, V>) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a new map containing all key-value pairs matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Map((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filter(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterKeys](../filter-keys) Returns a map containing all key-value pairs with keys matching the given [predicate](../filter-keys#kotlin.collections%24filterKeys(kotlin.collections.Map((kotlin.collections.filterKeys.K,%20kotlin.collections.filterKeys.V)),%20kotlin.Function1((kotlin.collections.filterKeys.K,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterKeys(     predicate: (K) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a new map containing all key-value pairs not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Map((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterNot(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all entries not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/predicate) into the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/destination). ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all entries matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/predicate) into the mutable map given as [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/destination) parameter. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterValues](../filter-values) Returns a map containing all key-value pairs with values matching the given [predicate](../filter-values#kotlin.collections%24filterValues(kotlin.collections.Map((kotlin.collections.filterValues.K,%20kotlin.collections.filterValues.V)),%20kotlin.Function1((kotlin.collections.filterValues.V,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterValues(     predicate: (V) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Map((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to entries of this map in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOf(     transform: (Entry<K, V>) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Map((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to entries of this map in iteration order, or `null` if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOfOrNull(     transform: (Entry<K, V>) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Iterable<R> ): List<R> ``` ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each entry of original map, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Iterable<R> ): C ``` ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Map((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Unit)))/action) on each entry. ``` fun <K, V> Map<out K, V>.forEach(     action: (Entry<K, V>) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [get](../get) Returns the value corresponding to the given [key](../get#kotlin.collections%24get(kotlin.collections.Map((kotlin.collections.get.K,%20kotlin.collections.get.V)),%20kotlin.collections.get.K)/key), or `null` if such a key is not present in the map. ``` operator fun <K, V> Map<out K, V>.get(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns the value for the given [key](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/key) if the value is present and not `null`. Otherwise, returns the result of the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/defaultValue) function. ``` fun <K, V> Map<K, V>.getOrElse(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrPut](../get-or-put) Returns the value for the given [key](../get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/key) if the value is present and not `null`. Otherwise, calls the [defaultValue](../get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/defaultValue) function, puts its result into the map under the given key and returns the call result. ``` fun <K, V> MutableMap<K, V>.getOrPut(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [getValue](../get-value) Returns the value for the given [key](../get-value#kotlin.collections%24getValue(kotlin.collections.Map((kotlin.collections.getValue.K,%20kotlin.collections.getValue.V)),%20kotlin.collections.getValue.K)/key) or throws an exception if there is no such key in the map. ``` fun <K, V> Map<K, V>.getValue(key: K): V ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this map if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.M,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the map is empty. ``` fun <M, R> M.ifEmpty(     defaultValue: () -> R ): R where M : Map<*, *>, M : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if this map is not empty. ``` fun <K, V> Map<out K, V>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable map is either null or empty. ``` fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Map((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.collections.map.R)))/transform) function to each entry in the original map. ``` fun <K, V, R> Map<out K, V>.map(     transform: (Entry<K, V>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeys](../map-keys) Returns a new Map with entries having the keys obtained by applying the [transform](../map-keys#kotlin.collections%24mapKeys(kotlin.collections.Map((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.collections.mapKeys.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R> Map<out K, V>.mapKeys(     transform: (Entry<K, V>) -> R ): Map<R, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeysTo](../map-keys-to) Populates the given [destination](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/destination) map with entries having the keys obtained by applying the [transform](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Map((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.collections.mapNotNull.R?)))/transform) function to each entry in the original map. ``` fun <K, V, R : Any> Map<out K, V>.mapNotNull(     transform: (Entry<K, V>) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each entry in the original map and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(     destination: C,     transform: (Entry<K, V>) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/transform) function to each entry of the original map and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(     destination: C,     transform: (Entry<K, V>) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValues](../map-values) Returns a new map with entries having the keys of this map and the values obtained by applying the [transform](../map-values#kotlin.collections%24mapValues(kotlin.collections.Map((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.collections.mapValues.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R> Map<out K, V>.mapValues(     transform: (Entry<K, V>) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValuesTo](../map-values-to) Populates the given [destination](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/destination) map with entries having the keys of this map and the values obtained by applying the [transform](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first entry yielding the largest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.maxOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first entry having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Map((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first entry having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Map((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.minOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minus](../minus) Returns a map containing all entries of the original map except the entry with the given [key](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.minus.K)/key). ``` operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.Iterable((kotlin.collections.minus.K)))/keys) collection. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Iterable<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.Array((kotlin.collections.minus.K)))/keys) array. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Array<out K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.sequences.Sequence((kotlin.collections.minus.K)))/keys) sequence. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Sequence<K> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minusAssign](../minus-assign) Removes the entry with the given [key](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.minusAssign.K)/key) from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) ``` Removes all entries the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.K)))/keys) collection from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Iterable<K>) ``` Removes all entries the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.Array((kotlin.collections.minusAssign.K)))/keys) array from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Array<out K>) ``` Removes all entries from the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.K)))/keys) sequence from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Sequence<K>) ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first entry having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Map((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first entry having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Map((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the map has no entries. ``` fun <K, V> Map<out K, V>.none(): Boolean ``` Returns `true` if no entries match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Map((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.none(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.onEach.K,%20kotlin.collections.onEach.V)),%20kotlin.Unit)))/action) on each entry and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEach(     action: (Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.M,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.Map.Entry((kotlin.collections.onEachIndexed.K,%20kotlin.collections.onEachIndexed.V)),%20kotlin.Unit)))/action) on each entry, providing sequential index with the entry, and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEachIndexed(     action: (index: Int, Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns the [Map](../-map/index#kotlin.collections.Map) if its not `null`, or the empty [Map](../-map/index#kotlin.collections.Map) otherwise. ``` fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair). ``` operator fun <K, V> Map<out K, V>.plus(     pair: Pair<K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Iterable<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Array<out Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Sequence<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from another [map](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map). ``` operator fun <K, V> Map<out K, V>.plus(     map: Map<out K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Appends or replaces the given [pair](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/pair) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pair: Pair<K, V>) ``` Appends or replaces all pairs from the given collection of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Iterable<Pair<K, V>>) ``` Appends or replaces all pairs from the given array of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Array<out Pair<K, V>>) ``` Appends or replaces all pairs from the given sequence of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Sequence<Pair<K, V>>) ``` Appends or replaces all entries from the given [map](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Map((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/map) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     map: Map<K, V>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [putAll](../put-all) Puts all the given [pairs](../put-all#kotlin.collections%24putAll(kotlin.collections.MutableMap((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)))))/pairs) into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Array<out Pair<K, V>>) ``` Puts all the elements of the given collection into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Iterable<Pair<K, V>>) ``` Puts all the elements of the given sequence into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Sequence<Pair<K, V>>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes the specified key and its corresponding value from this map. ``` fun <K, V> MutableMap<out K, V>.remove(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [set](../set) Allows to use the index operator for storing values in a mutable map. ``` operator fun <K, V> MutableMap<K, V>.set(key: K, value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [setValue](../set-value) Stores the value of the property for the given object in this mutable map. ``` operator fun <V> MutableMap<in String, in V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all key-value pairs. ``` fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMap](../to-map) Returns a new read-only map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Map((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given map. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMutableMap](../to-mutable-map) Returns a new mutable map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0) #### [toProperties](../to-properties) Converts this [Map](../-map/index#kotlin.collections.Map) to a [Properties](https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html) object. ``` fun Map<String, String>.toProperties(): Properties ``` **Platform and version requirements:** JVM (1.0) #### [toSortedMap](../to-sorted-map) Converts this [Map](../-map/index#kotlin.collections.Map) to a [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to the sorting order provided by the given [comparator](../to-sorted-map#kotlin.collections%24toSortedMap(kotlin.collections.Map((kotlin.collections.toSortedMap.K,%20kotlin.collections.toSortedMap.V)),%20java.util.Comparator((kotlin.collections.toSortedMap.K)))/comparator). ``` fun <K, V> Map<out K, V>.toSortedMap(     comparator: Comparator<in K> ): SortedMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withDefault](../with-default) Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.Map((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> Map<K, V>.withDefault(     defaultValue: (key: K) -> V ): Map<K, V> ``` Returns a wrapper of this mutable map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.MutableMap((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> MutableMap<K, V>.withDefault(     defaultValue: (key: K) -> V ): MutableMap<K, V> ``` Inheritors ---------- #### [HashMap](../-hash-map/index) Hash table based implementation of the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface. **Platform and version requirements:** ``` class HashMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` typealias HashMap<K, V> = HashMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` open class HashMap<K, V> :      AbstractMutableMap<K, V>,     MutableMap<K, V> ```
programming_docs
kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / <remove> **Platform and version requirements:** JS (1.1) ``` open fun remove(key: K): V? ``` Removes the specified key and its corresponding value from this map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. kotlin keys keys ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / <keys> **Platform and version requirements:** JS (1.1) ``` open val keys: MutableSet<K> ``` Returns a [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) of all keys in this map. kotlin containsKey containsKey =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / [containsKey](contains-key) **Platform and version requirements:** ``` open fun containsKey(key: K): Boolean ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1) ``` protected <init>() ``` Provides a skeletal implementation of the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface. The implementor is required to implement [entries](../-mutable-map/entries#kotlin.collections.MutableMap%24entries) property, which should return mutable set of map entries, and [put](put#kotlin.collections.AbstractMutableMap%24put(kotlin.collections.AbstractMutableMap.K,%20kotlin.collections.AbstractMutableMap.V)) function. Parameters ---------- `K` - the type of map keys. The map is invariant in its key type. `V` - the type of map values. The map is invariant in its value type. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / <clear> **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` Removes all elements from this map. kotlin entries entries ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / <entries> **Platform and version requirements:** ``` abstract val entries: MutableSet<MutableEntry<K, V>> ``` kotlin put put === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / <put> **Platform and version requirements:** JVM (1.0), JS (1.1) ``` abstract fun put(key: K, value: V): V? ``` ##### For Common, JVM Associates the specified [value](put#kotlin.collections.AbstractMutableMap%24put(kotlin.collections.AbstractMutableMap.K,%20kotlin.collections.AbstractMutableMap.V)/value) with the specified [key](put#kotlin.collections.AbstractMutableMap%24put(kotlin.collections.AbstractMutableMap.K,%20kotlin.collections.AbstractMutableMap.V)/key) in the map. This method is redeclared as abstract, because it's not implemented in the base class, so it must be always overridden in the concrete mutable collection implementation. **Return** the previous value associated with the key, or `null` if the key was not present in the map. ##### For JS Associates the specified [value](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/value) with the specified [key](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/key) in the map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` open fun isEmpty(): Boolean ``` kotlin containsValue containsValue ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / [containsValue](contains-value) **Platform and version requirements:** ``` open fun containsValue(value: V): Boolean ``` kotlin putAll putAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / [putAll](put-all) **Platform and version requirements:** JS (1.1) ``` open fun putAll(from: Map<out K, V>) ``` Updates this map with key/value pairs from the specified map [from](../-mutable-map/put-all#kotlin.collections.MutableMap%24putAll(kotlin.collections.Map((kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)))/from). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableMap](index) / <get> **Platform and version requirements:** ``` open fun get(key: K): V? ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val size: Int ``` Returns the number of key/value pairs in the map. kotlin values values ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / <values> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val values: Collection<V> ``` Returns a read-only [Collection](../-collection/index#kotlin.collections.Collection) of all values in this map. Note that this collection may contain duplicate values. kotlin Map Map === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface Map<K, out V> ``` A collection that holds pairs of objects (keys and values) and supports efficiently retrieving the value corresponding to each key. Map keys are unique; the map holds only one value for each key. Methods in this interface support only read-only access to the map; read-write access is supported through the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface. Parameters ---------- `K` - the type of map keys. The map is invariant in its key type, as it can accept key as a parameter (of [containsKey](contains-key#kotlin.collections.Map%24containsKey(kotlin.collections.Map.K)) for example) and return it in [keys](keys#kotlin.collections.Map%24keys) set. `V` - the type of map values. The map is covariant in its value type. Types ----- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Entry](-entry/index) Represents a key/value pair held by a [Map](index#kotlin.collections.Map). ``` interface Entry<out K, out V> ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <entries> Returns a read-only [Set](../-set/index#kotlin.collections.Set) of all key/value pairs in this map. ``` abstract val entries: Set<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <keys> Returns a read-only [Set](../-set/index#kotlin.collections.Set) of all keys in this map. ``` abstract val keys: Set<K> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> Returns the number of key/value pairs in the map. ``` abstract val size: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <values> Returns a read-only [Collection](../-collection/index#kotlin.collections.Collection) of all values in this map. Note that this collection may contain duplicate values. ``` abstract val values: Collection<V> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](contains-key) Returns `true` if the map contains the specified [key](contains-key#kotlin.collections.Map%24containsKey(kotlin.collections.Map.K)/key). ``` abstract fun containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](contains-value) Returns `true` if the map maps one or more keys to the specified [value](contains-value#kotlin.collections.Map%24containsValue(kotlin.collections.Map.V)/value). ``` abstract fun containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the value corresponding to the given [key](get#kotlin.collections.Map%24get(kotlin.collections.Map.K)/key), or `null` if such a key is not present in the map. ``` abstract operator fun get(key: K): V? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [getOrDefault](get-or-default) Returns the value corresponding to the given [key](get-or-default#kotlin.collections.Map%24getOrDefault(kotlin.collections.Map.K,%20kotlin.collections.Map.V)/key), or [defaultValue](get-or-default#kotlin.collections.Map%24getOrDefault(kotlin.collections.Map.K,%20kotlin.collections.Map.V)/defaultValue) if such a key is not present in the map. ``` open fun getOrDefault(key: K, defaultValue: V): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Returns `true` if the map is empty (contains no elements), `false` otherwise. ``` abstract fun isEmpty(): Boolean ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all entries match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Map((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.all(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if map has at least one entry. ``` fun <K, V> Map<out K, V>.any(): Boolean ``` Returns `true` if at least one entry matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Map((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.any(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Creates an [Iterable](../-iterable/index#kotlin.collections.Iterable) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Checks if the map contains the given key. ``` operator fun <K, V> Map<out K, V>.contains(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](../contains-key) Returns `true` if the map contains the specified [key](../contains-key#kotlin.collections%24containsKey(kotlin.collections.Map((kotlin.collections.containsKey.K,%20kotlin.Any?)),%20kotlin.collections.containsKey.K)/key). ``` fun <K> Map<out K, *>.containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](../contains-value) Returns `true` if the map maps one or more keys to the specified [value](../contains-value#kotlin.collections%24containsValue(kotlin.collections.Map((kotlin.collections.containsValue.K,%20kotlin.collections.containsValue.V)),%20kotlin.collections.containsValue.V)/value). ``` fun <K, V> Map<K, V>.containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of entries in this map. ``` fun <K, V> Map<out K, V>.count(): Int ``` Returns the number of entries matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Map((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.count(     predicate: (Entry<K, V>) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a new map containing all key-value pairs matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Map((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filter(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterKeys](../filter-keys) Returns a map containing all key-value pairs with keys matching the given [predicate](../filter-keys#kotlin.collections%24filterKeys(kotlin.collections.Map((kotlin.collections.filterKeys.K,%20kotlin.collections.filterKeys.V)),%20kotlin.Function1((kotlin.collections.filterKeys.K,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterKeys(     predicate: (K) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a new map containing all key-value pairs not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Map((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterNot(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all entries not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/predicate) into the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/destination). ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all entries matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/predicate) into the mutable map given as [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/destination) parameter. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterValues](../filter-values) Returns a map containing all key-value pairs with values matching the given [predicate](../filter-values#kotlin.collections%24filterValues(kotlin.collections.Map((kotlin.collections.filterValues.K,%20kotlin.collections.filterValues.V)),%20kotlin.Function1((kotlin.collections.filterValues.V,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterValues(     predicate: (V) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Map((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to entries of this map in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOf(     transform: (Entry<K, V>) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Map((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to entries of this map in iteration order, or `null` if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOfOrNull(     transform: (Entry<K, V>) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Iterable<R> ): List<R> ``` ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each entry of original map, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Iterable<R> ): C ``` ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Map((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Unit)))/action) on each entry. ``` fun <K, V> Map<out K, V>.forEach(     action: (Entry<K, V>) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [get](../get) Returns the value corresponding to the given [key](../get#kotlin.collections%24get(kotlin.collections.Map((kotlin.collections.get.K,%20kotlin.collections.get.V)),%20kotlin.collections.get.K)/key), or `null` if such a key is not present in the map. ``` operator fun <K, V> Map<out K, V>.get(key: K): V? ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2) #### [getOrDefault](../get-or-default) Returns the value to which the specified key is mapped, or [defaultValue](../get-or-default#kotlin.collections%24getOrDefault(kotlin.collections.Map((kotlin.collections.getOrDefault.K,%20kotlin.collections.getOrDefault.V)),%20kotlin.collections.getOrDefault.K,%20kotlin.collections.getOrDefault.V)/defaultValue) if this map contains no mapping for the key. ``` fun <K, V> Map<out K, V>.getOrDefault(     key: K,     defaultValue: V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns the value for the given [key](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/key) if the value is present and not `null`. Otherwise, returns the result of the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/defaultValue) function. ``` fun <K, V> Map<K, V>.getOrElse(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getValue](../get-value) Returns the value of the property for the given object from this read-only map. ``` operator fun <V, V1 : V> Map<in String, V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V1 ``` Returns the value for the given [key](../get-value#kotlin.collections%24getValue(kotlin.collections.Map((kotlin.collections.getValue.K,%20kotlin.collections.getValue.V)),%20kotlin.collections.getValue.K)/key) or throws an exception if there is no such key in the map. ``` fun <K, V> Map<K, V>.getValue(key: K): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if this map is not empty. ``` fun <K, V> Map<out K, V>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable map is either null or empty. ``` fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) over the entries in the [Map](index#kotlin.collections.Map). ``` operator fun <K, V> Map<out K, V>.iterator(): Iterator<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Map((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.collections.map.R)))/transform) function to each entry in the original map. ``` fun <K, V, R> Map<out K, V>.map(     transform: (Entry<K, V>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeys](../map-keys) Returns a new Map with entries having the keys obtained by applying the [transform](../map-keys#kotlin.collections%24mapKeys(kotlin.collections.Map((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.collections.mapKeys.R)))/transform) function to each entry in this [Map](index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R> Map<out K, V>.mapKeys(     transform: (Entry<K, V>) -> R ): Map<R, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeysTo](../map-keys-to) Populates the given [destination](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/destination) map with entries having the keys obtained by applying the [transform](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/transform) function to each entry in this [Map](index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Map((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.collections.mapNotNull.R?)))/transform) function to each entry in the original map. ``` fun <K, V, R : Any> Map<out K, V>.mapNotNull(     transform: (Entry<K, V>) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each entry in the original map and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(     destination: C,     transform: (Entry<K, V>) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/transform) function to each entry of the original map and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(     destination: C,     transform: (Entry<K, V>) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValues](../map-values) Returns a new map with entries having the keys of this map and the values obtained by applying the [transform](../map-values#kotlin.collections%24mapValues(kotlin.collections.Map((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.collections.mapValues.R)))/transform) function to each entry in this [Map](index#kotlin.collections.Map). ``` fun <K, V, R> Map<out K, V>.mapValues(     transform: (Entry<K, V>) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValuesTo](../map-values-to) Populates the given [destination](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/destination) map with entries having the keys of this map and the values obtained by applying the [transform](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/transform) function to each entry in this [Map](index#kotlin.collections.Map). ``` fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first entry yielding the largest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.maxOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first entry having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Map((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first entry having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Map((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.minOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minus](../minus) Returns a map containing all entries of the original map except the entry with the given [key](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.minus.K)/key). ``` operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.Iterable((kotlin.collections.minus.K)))/keys) collection. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Iterable<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.Array((kotlin.collections.minus.K)))/keys) array. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Array<out K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.sequences.Sequence((kotlin.collections.minus.K)))/keys) sequence. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Sequence<K> ): Map<K, V> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first entry having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Map((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.0) ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first entry having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Map((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the map has no entries. ``` fun <K, V> Map<out K, V>.none(): Boolean ``` Returns `true` if no entries match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Map((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.none(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.onEach.K,%20kotlin.collections.onEach.V)),%20kotlin.Unit)))/action) on each entry and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEach(     action: (Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.M,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.Map.Entry((kotlin.collections.onEachIndexed.K,%20kotlin.collections.onEachIndexed.V)),%20kotlin.Unit)))/action) on each entry, providing sequential index with the entry, and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEachIndexed(     action: (index: Int, Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns the [Map](index#kotlin.collections.Map) if its not `null`, or the empty [Map](index#kotlin.collections.Map) otherwise. ``` fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair). ``` operator fun <K, V> Map<out K, V>.plus(     pair: Pair<K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Iterable<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Array<out Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Sequence<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from another [map](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map). ``` operator fun <K, V> Map<out K, V>.plus(     map: Map<out K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all key-value pairs. ``` fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMap](../to-map) Returns a new read-only map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Map((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given map. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMutableMap](../to-mutable-map) Returns a new mutable map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0) #### [toProperties](../to-properties) Converts this [Map](index#kotlin.collections.Map) to a [Properties](https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html) object. ``` fun Map<String, String>.toProperties(): Properties ``` **Platform and version requirements:** JVM (1.0) #### [toSortedMap](../to-sorted-map) Converts this [Map](index#kotlin.collections.Map) to a [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to their natural sorting order. ``` fun <K : Comparable<K>, V> Map<out K, V>.toSortedMap(): SortedMap<K, V> ``` Converts this [Map](index#kotlin.collections.Map) to a [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). The resulting [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html) determines the equality and order of keys according to the sorting order provided by the given [comparator](../to-sorted-map#kotlin.collections%24toSortedMap(kotlin.collections.Map((kotlin.collections.toSortedMap.K,%20kotlin.collections.toSortedMap.V)),%20java.util.Comparator((kotlin.collections.toSortedMap.K)))/comparator). ``` fun <K, V> Map<out K, V>.toSortedMap(     comparator: Comparator<in K> ): SortedMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withDefault](../with-default) Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.Map((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> Map<K, V>.withDefault(     defaultValue: (key: K) -> V ): Map<K, V> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractMap](../-abstract-map/index) Provides a skeletal implementation of the read-only [Map](index#kotlin.collections.Map) interface. ``` abstract class AbstractMap<K, out V> : Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableMap](../-mutable-map/index) A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving the value corresponding to each key. Map keys are unique; the map holds only one value for each key. ``` interface MutableMap<K, V> : Map<K, V> ```
programming_docs
kotlin getOrDefault getOrDefault ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / [getOrDefault](get-or-default) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` open fun getOrDefault(     key: K,     defaultValue: @UnsafeVariance V ): V ``` Returns the value corresponding to the given [key](get-or-default#kotlin.collections.Map%24getOrDefault(kotlin.collections.Map.K,%20kotlin.collections.Map.V)/key), or [defaultValue](get-or-default#kotlin.collections.Map%24getOrDefault(kotlin.collections.Map.K,%20kotlin.collections.Map.V)/defaultValue) if such a key is not present in the map. **Since** JDK 1.8 kotlin keys keys ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / <keys> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val keys: Set<K> ``` Returns a read-only [Set](../-set/index#kotlin.collections.Set) of all keys in this map. kotlin containsKey containsKey =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / [containsKey](contains-key) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun containsKey(key: K): Boolean ``` Returns `true` if the map contains the specified [key](contains-key#kotlin.collections.Map%24containsKey(kotlin.collections.Map.K)/key). kotlin entries entries ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / <entries> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val entries: Set<Entry<K, V>> ``` Returns a read-only [Set](../-set/index#kotlin.collections.Set) of all key/value pairs in this map. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun isEmpty(): Boolean ``` Returns `true` if the map is empty (contains no elements), `false` otherwise. kotlin containsValue containsValue ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / [containsValue](contains-value) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun containsValue(value: @UnsafeVariance V): Boolean ``` Returns `true` if the map maps one or more keys to the specified [value](contains-value#kotlin.collections.Map%24containsValue(kotlin.collections.Map.V)/value). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Map](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract operator fun get(key: K): V? ``` Returns the value corresponding to the given [key](get#kotlin.collections.Map%24get(kotlin.collections.Map.K)/key), or `null` if such a key is not present in the map. kotlin Entry Entry ===== [kotlin-stdlib](../../../../../../../index) / [kotlin.collections](../../index) / [Map](../index) / [Entry](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface Entry<out K, out V> ``` Represents a key/value pair held by a [Map](../index#kotlin.collections.Map). Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <key> Returns the key of this key/value pair. ``` abstract val key: K ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <value> Returns the value of this key/value pair. ``` abstract val value: V ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../component1) Returns the key component of the map entry. ``` operator fun <K, V> Entry<K, V>.component1(): K ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../component2) Returns the value component of the map entry. ``` operator fun <K, V> Entry<K, V>.component2(): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toPair](../../to-pair) Converts entry to [Pair](../../../kotlin/-pair/index) with key being first component and value being second. ``` fun <K, V> Entry<K, V>.toPair(): Pair<K, V> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableEntry](../../-mutable-map/-mutable-entry/index) Represents a key/value pair held by a [MutableMap](../../-mutable-map/index#kotlin.collections.MutableMap). ``` interface MutableEntry<K, V> : Entry<K, V> ``` kotlin value value ===== [kotlin-stdlib](../../../../../../../index) / [kotlin.collections](../../index) / [Map](../index) / [Entry](index) / <value> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val value: V ``` Returns the value of this key/value pair. kotlin key key === [kotlin-stdlib](../../../../../../../index) / [kotlin.collections](../../index) / [Map](../index) / [Entry](index) / <key> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val key: K ``` Returns the key of this key/value pair. kotlin toArray toArray ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [toArray](to-array) **Platform and version requirements:** JS (1.1) ``` protected open fun <T> toArray(array: Array<T>): Array<T> ``` ``` protected open fun toArray(): Array<Any?> ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / <contains> **Platform and version requirements:** ``` fun contains(element: @UnsafeVariance E): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / <size> **Platform and version requirements:** ``` val size: Int ``` **Platform and version requirements:** JS (1.1) ``` open val size: Int ``` kotlin ArrayList ArrayList ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) **Platform and version requirements:** ``` class ArrayList<E> : MutableList<E>, RandomAccess ``` **Platform and version requirements:** JVM (1.1) ``` typealias ArrayList<E> = ArrayList<E> ``` **Platform and version requirements:** JS (1.1) ``` open class ArrayList<E> :      AbstractMutableList<E>,     MutableList<E>,     RandomAccess ``` Provides a [MutableList](../-mutable-list/index#kotlin.collections.MutableList) implementation, which uses a resizable array as its backing storage. This implementation doesn't provide a way to manage capacity, as backing JS array is resizeable itself. There is no speed advantage to pre-allocating array sizes in JavaScript, so this implementation does not include any of the capacity and "growth increment" concepts. Constructors ------------ **Platform and version requirements:** JS (1.0) #### [<init>](-init-) Creates an empty [ArrayList](index#kotlin.collections.ArrayList). ``` <init>() ``` ``` <init>(initialCapacity: Int) ``` Creates an [ArrayList](index#kotlin.collections.ArrayList) filled from the elements collection. ``` <init>(elements: Collection<E>) ``` Properties ---------- #### <size> **Platform and version requirements:** ``` val size: Int ``` **Platform and version requirements:** JS (1.1) ``` open val size: Int ``` Inherited Properties -------------------- **Platform and version requirements:** JS (1.1) #### [modCount](../-abstract-mutable-list/mod-count) ``` var modCount: Int ``` Functions --------- #### <add> Adds the specified element to the end of this list. **Platform and version requirements:** ``` fun add(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun add(element: E): Boolean ``` Inserts an element into the list at the specified [index](../-mutable-list/add#kotlin.collections.MutableList%24add(kotlin.Int,%20kotlin.collections.MutableList.E)/index). **Platform and version requirements:** ``` fun add(index: Int, element: E) ``` **Platform and version requirements:** JS (1.1) ``` open fun add(index: Int, element: E) ``` #### [addAll](add-all) Adds all of the elements of the specified collection to the end of this list. **Platform and version requirements:** ``` fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun addAll(elements: Collection<E>): Boolean ``` Inserts all of the elements of the specified collection [elements](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/elements) into this list at the specified [index](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/index). **Platform and version requirements:** ``` fun addAll(index: Int, elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun addAll(index: Int, elements: Collection<E>): Boolean ``` #### <clear> Removes all elements from this collection. **Platform and version requirements:** ``` fun clear() ``` **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` **Platform and version requirements:** #### <contains> ``` fun contains(element: E): Boolean ``` **Platform and version requirements:** #### [containsAll](contains-all) ``` fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.0) #### [ensureCapacity](ensure-capacity) Does nothing in this ArrayList implementation. ``` fun ensureCapacity(minCapacity: Int) ``` #### <get> Returns the element at the specified index in the list. **Platform and version requirements:** ``` operator fun get(index: Int): E ``` **Platform and version requirements:** JS (1.1) ``` open fun get(index: Int): E ``` #### [indexOf](index-of) Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. **Platform and version requirements:** ``` fun indexOf(element: E): Int ``` **Platform and version requirements:** JS (1.1) ``` open fun indexOf(element: E): Int ``` **Platform and version requirements:** #### [isEmpty](is-empty) ``` fun isEmpty(): Boolean ``` **Platform and version requirements:** #### <iterator> ``` fun iterator(): MutableIterator<E> ``` #### [lastIndexOf](last-index-of) Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. **Platform and version requirements:** ``` fun lastIndexOf(element: E): Int ``` **Platform and version requirements:** JS (1.1) ``` open fun lastIndexOf(element: E): Int ``` **Platform and version requirements:** #### [listIterator](list-iterator) ``` fun listIterator(): MutableListIterator<E> ``` ``` fun listIterator(index: Int): MutableListIterator<E> ``` #### <remove> Removes a single instance of the specified element from this collection, if it is present. **Platform and version requirements:** ``` fun remove(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun remove(element: E): Boolean ``` **Platform and version requirements:** #### [removeAll](remove-all) ``` fun removeAll(elements: Collection<E>): Boolean ``` #### [removeAt](remove-at) Removes an element at the specified [index](../-mutable-list/remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)/index) from the list. **Platform and version requirements:** ``` fun removeAt(index: Int): E ``` **Platform and version requirements:** JS (1.1) ``` open fun removeAt(index: Int): E ``` **Platform and version requirements:** JS (1.1) #### [removeRange](remove-range) Removes the range of elements from this list starting from [fromIndex](../-abstract-mutable-list/remove-range#kotlin.collections.AbstractMutableList%24removeRange(kotlin.Int,%20kotlin.Int)/fromIndex) and ending with but not including [toIndex](../-abstract-mutable-list/remove-range#kotlin.collections.AbstractMutableList%24removeRange(kotlin.Int,%20kotlin.Int)/toIndex). ``` open fun removeRange(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** #### [retainAll](retain-all) ``` fun retainAll(elements: Collection<E>): Boolean ``` #### <set> Replaces the element at the specified position in this list with the specified element. **Platform and version requirements:** ``` operator fun set(index: Int, element: E): E ``` **Platform and version requirements:** JS (1.1) ``` open fun set(index: Int, element: E): E ``` **Platform and version requirements:** #### [subList](sub-list) ``` fun subList(fromIndex: Int, toIndex: Int): MutableList<E> ``` **Platform and version requirements:** JS (1.1) #### [toArray](to-array) ``` open fun <T> toArray(array: Array<T>): Array<T> ``` ``` open fun toArray(): Array<Any?> ``` **Platform and version requirements:** JS (1.1) #### [toString](to-string) ``` open fun toString(): String ``` **Platform and version requirements:** JS (1.0) #### [trimToSize](trim-to-size) Does nothing in this ArrayList implementation. ``` fun trimToSize() ``` Inherited Functions ------------------- **Platform and version requirements:** #### [containsAll](../-abstract-mutable-list/contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) #### [equals](../-abstract-mutable-list/equals) Compares this list with another list instance with the ordered structural equality. ``` open fun equals(other: Any?): Boolean ``` **Platform and version requirements:** JS (1.1) #### [hashCode](../-abstract-mutable-list/hash-code) Returns the hash code value for this list. ``` open fun hashCode(): Int ``` **Platform and version requirements:** #### [isEmpty](../-abstract-mutable-list/is-empty) ``` open fun isEmpty(): Boolean ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../last-index) Returns the index of the last item in the list or -1 if the list is empty. ``` val <T> List<T>.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearch](../binary-search) Searches this list or its range for the provided [element](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for an element for which the given [comparison](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearchBy](../binary-search-by) Searches this list or its range for an element having the key returned by the specified [selector](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. ``` fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     selector: (T) -> K? ): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../component1) Returns 1st *element* from the list. ``` operator fun <T> List<T>.component1(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../component2) Returns 2nd *element* from the list. ``` operator fun <T> List<T>.component2(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../component3) Returns 3rd *element* from the list. ``` operator fun <T> List<T>.component3(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../component4) Returns 4th *element* from the list. ``` operator fun <T> List<T>.component4(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../component5) Returns 5th *element* from the list. ``` operator fun <T> List<T>.component5(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](../drop-last) Returns a list containing all elements except last [n](../drop-last#kotlin.collections%24dropLast(kotlin.collections.List((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](../drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](../drop-last-while#kotlin.collections%24dropLastWhile(kotlin.collections.List((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](../fold-right) Accumulates value starting with [initial](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](../fold-right-indexed) Accumulates value starting with [initial](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns an element at the given [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](../get-or-null) Returns an element at the given [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.getOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` ``` fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](../reduce-right) Accumulates value starting with the last element and applying [operation](../reduce-right#kotlin.collections%24reduceRight(kotlin.collections.List((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](../reduce-right-indexed) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](../reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](../reduce-right-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.collections.List((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` Removes the element at the specified [index](../remove#kotlin.collections%24remove(kotlin.collections.MutableList((kotlin.collections.remove.T)),%20kotlin.Int)/index) from this list. In Kotlin one should use the [MutableList.removeAt](../-mutable-list/remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)) function instead. ``` fun <T> MutableList<T>.remove(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` Removes all elements from this [MutableList](../-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableList((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirst](../remove-first) Removes the first element from this mutable list and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeFirst(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirstOrNull](../remove-first-or-null) Removes the first element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeFirstOrNull(): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLast](../remove-last) Removes the last element from this mutable list and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeLast(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLastOrNull](../remove-last-or-null) Removes the last element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeLastOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` Retains only elements of this [MutableList](../-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableList((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffle](../shuffle) Randomly shuffles elements in this list in-place using the specified [random](../shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> MutableList<T>.shuffle(random: Random) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [slice](../slice) Returns a list containing elements at indices in the specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` Returns a list containing elements at specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortBy](../sort-by) Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector](../sort-by#kotlin.collections%24sortBy(kotlin.collections.MutableList((kotlin.collections.sortBy.T)),%20kotlin.Function1((kotlin.collections.sortBy.T,%20kotlin.collections.sortBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortBy(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortByDescending](../sort-by-descending) Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector](../sort-by-descending#kotlin.collections%24sortByDescending(kotlin.collections.MutableList((kotlin.collections.sortByDescending.T)),%20kotlin.Function1((kotlin.collections.sortByDescending.T,%20kotlin.collections.sortByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](../take-last) Returns a list containing last [n](../take-last#kotlin.collections%24takeLast(kotlin.collections.List((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](../take-last-while) Returns a list containing last elements satisfying the given [predicate](../take-last-while#kotlin.collections%24takeLastWhile(kotlin.collections.List((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ```
programming_docs
kotlin trimToSize trimToSize ========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [trimToSize](trim-to-size) **Platform and version requirements:** JS (1.1) ``` fun trimToSize() ``` Does nothing in this ArrayList implementation. kotlin listIterator listIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [listIterator](list-iterator) **Platform and version requirements:** ``` fun listIterator(): MutableListIterator<E> ``` ``` fun listIterator(index: Int): MutableListIterator<E> ``` kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / <add> **Platform and version requirements:** ``` fun add(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun add(element: E): Boolean ``` Adds the specified element to the end of this list. **Return** `true` because the list is always modified as the result of this operation. **Platform and version requirements:** ``` fun add(index: Int, element: E) ``` **Platform and version requirements:** JS (1.1) ``` open fun add(index: Int, element: E) ``` Inserts an element into the list at the specified [index](../-mutable-list/add#kotlin.collections.MutableList%24add(kotlin.Int,%20kotlin.collections.MutableList.E)/index). kotlin removeRange removeRange =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [removeRange](remove-range) **Platform and version requirements:** JS (1.1) ``` protected open fun removeRange(fromIndex: Int, toIndex: Int) ``` Overrides [AbstractMutableList.removeRange](../-abstract-mutable-list/remove-range) Removes the range of elements from this list starting from [fromIndex](../-abstract-mutable-list/remove-range#kotlin.collections.AbstractMutableList%24removeRange(kotlin.Int,%20kotlin.Int)/fromIndex) and ending with but not including [toIndex](../-abstract-mutable-list/remove-range#kotlin.collections.AbstractMutableList%24removeRange(kotlin.Int,%20kotlin.Int)/toIndex). kotlin lastIndexOf lastIndexOf =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [lastIndexOf](last-index-of) **Platform and version requirements:** ``` fun lastIndexOf(element: @UnsafeVariance E): Int ``` **Platform and version requirements:** JS (1.1) ``` open fun lastIndexOf(element: E): Int ``` Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / <remove> **Platform and version requirements:** ``` fun remove(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun remove(element: E): Boolean ``` Removes a single instance of the specified element from this collection, if it is present. **Return** `true` if the element has been successfully removed; `false` if it was not present in the collection. kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [retainAll](retain-all) **Platform and version requirements:** ``` fun retainAll(elements: Collection<E>): Boolean ``` kotlin removeAt removeAt ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [removeAt](remove-at) **Platform and version requirements:** ``` fun removeAt(index: Int): E ``` **Platform and version requirements:** JS (1.1) ``` open fun removeAt(index: Int): E ``` Removes an element at the specified [index](../-mutable-list/remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)/index) from the list. **Return** the element that has been removed. kotlin subList subList ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [subList](sub-list) **Platform and version requirements:** ``` fun subList(fromIndex: Int, toIndex: Int): MutableList<E> ``` kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / <iterator> **Platform and version requirements:** ``` fun iterator(): MutableIterator<E> ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [toString](to-string) **Platform and version requirements:** JS (1.1) ``` open fun toString(): String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0) ``` <init>() ``` Creates an empty [ArrayList](index#kotlin.collections.ArrayList). **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int) ``` Creates an empty [ArrayList](index#kotlin.collections.ArrayList). Parameters ---------- `initialCapacity` - initial capacity (ignored) **Platform and version requirements:** JS (1.0) ``` <init>(elements: Collection<E>) ``` Creates an [ArrayList](index#kotlin.collections.ArrayList) filled from the elements collection. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [removeAll](remove-all) **Platform and version requirements:** ``` fun removeAll(elements: Collection<E>): Boolean ``` kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / <clear> **Platform and version requirements:** ``` fun clear() ``` **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` Removes all elements from this collection. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [containsAll](contains-all) **Platform and version requirements:** ``` fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` fun isEmpty(): Boolean ``` kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [addAll](add-all) **Platform and version requirements:** ``` fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun addAll(elements: Collection<E>): Boolean ``` Adds all of the elements of the specified collection to the end of this list. The elements are appended in the order they appear in the [elements](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.collections.Collection((kotlin.collections.MutableList.E)))/elements) collection. **Return** `true` if the list was changed as the result of the operation. **Platform and version requirements:** ``` fun addAll(index: Int, elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun addAll(index: Int, elements: Collection<E>): Boolean ``` Inserts all of the elements of the specified collection [elements](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/elements) into this list at the specified [index](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/index). **Return** `true` if the list was changed as the result of the operation. kotlin indexOf indexOf ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [indexOf](index-of) **Platform and version requirements:** ``` fun indexOf(element: @UnsafeVariance E): Int ``` **Platform and version requirements:** JS (1.1) ``` open fun indexOf(element: E): Int ``` Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / <set> **Platform and version requirements:** ``` operator fun set(index: Int, element: E): E ``` **Platform and version requirements:** JS (1.1) ``` open fun set(index: Int, element: E): E ``` Replaces the element at the specified position in this list with the specified element. **Return** the element previously at the specified position. kotlin ensureCapacity ensureCapacity ============== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / [ensureCapacity](ensure-capacity) **Platform and version requirements:** JS (1.1) ``` fun ensureCapacity(minCapacity: Int) ``` Does nothing in this ArrayList implementation. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ArrayList](index) / <get> **Platform and version requirements:** ``` operator fun get(index: Int): E ``` **Platform and version requirements:** JS (1.1) ``` open fun get(index: Int): E ``` Returns the element at the specified index in the list. kotlin CharIterator CharIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [CharIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class CharIterator : Iterator<Char> ``` An iterator over a sequence of values of type `Char`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An iterator over a sequence of values of type `Char`. ``` CharIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` fun next(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextChar](next-char) Returns the next value in the sequence without boxing. ``` abstract fun nextChar(): Char ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin nextChar nextChar ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [CharIterator](index) / [nextChar](next-char) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun nextChar(): Char ``` Returns the next value in the sequence without boxing. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [CharIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` CharIterator() ``` An iterator over a sequence of values of type `Char`. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [CharIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun next(): Char ``` kotlin Iterator Iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Iterator](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface Iterator<out T> ``` An iterator over a collection or another entity that can be represented as a sequence of elements. Allows to sequentially access the elements. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hasNext](has-next) Returns `true` if the iteration has more elements. ``` abstract operator fun hasNext(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> Returns the next element in the iteration. ``` abstract operator fun next(): T ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AbstractIterator](../-abstract-iterator/index) A base class to simplify implementing iterators so that implementations only have to implement [computeNext](../-abstract-iterator/compute-next) to implement the iterator, calling [done](../-abstract-iterator/done) when the iteration is complete. ``` abstract class AbstractIterator<T> : Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [BooleanIterator](../-boolean-iterator/index) An iterator over a sequence of values of type `Boolean`. ``` abstract class BooleanIterator : Iterator<Boolean> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ByteIterator](../-byte-iterator/index) An iterator over a sequence of values of type `Byte`. ``` abstract class ByteIterator : Iterator<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharIterator](../-char-iterator/index) An iterator over a sequence of values of type `Char`. ``` abstract class CharIterator : Iterator<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [DoubleIterator](../-double-iterator/index) An iterator over a sequence of values of type `Double`. ``` abstract class DoubleIterator : Iterator<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FloatIterator](../-float-iterator/index) An iterator over a sequence of values of type `Float`. ``` abstract class FloatIterator : Iterator<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntIterator](../-int-iterator/index) An iterator over a sequence of values of type `Int`. ``` abstract class IntIterator : Iterator<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ListIterator](../-list-iterator/index) An iterator over a collection that supports indexed access. ``` interface ListIterator<out T> : Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongIterator](../-long-iterator/index) An iterator over a sequence of values of type `Long`. ``` abstract class LongIterator : Iterator<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableIterator](../-mutable-iterator/index) An iterator over a mutable collection. Provides the ability to remove elements while iterating. ``` interface MutableIterator<out T> : Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ShortIterator](../-short-iterator/index) An iterator over a sequence of values of type `Short`. ``` abstract class ShortIterator : Iterator<Short> ``` kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Iterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract operator fun next(): T ``` Returns the next element in the iteration. kotlin hasNext hasNext ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Iterator](index) / [hasNext](has-next) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract operator fun hasNext(): Boolean ``` Returns `true` if the iteration has more elements. kotlin MutableSet MutableSet ========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableSet](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface MutableSet<E> : Set<E>, MutableCollection<E> ``` A generic unordered collection of elements that does not support duplicate elements, and supports adding and removing elements. Parameters ---------- `E` - the type of elements contained in the set. The mutable set is invariant in its element type. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <add> Adds the specified element to the set. ``` abstract fun add(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](add-all) Adds all of the elements of the specified collection to this collection. ``` abstract fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <clear> Removes all elements from this collection. ``` abstract fun clear() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns an iterator over the elements of this object. ``` abstract fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <remove> Removes a single instance of the specified element from this collection, if it is present. ``` abstract fun remove(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` abstract fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` abstract fun retainAll(elements: Collection<E>): Boolean ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Set<T>.minus(element: T): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Set((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Set<T>.minusElement(element: T): Set<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element) if it isn't already in this set. ``` operator fun <T> Set<T>.plus(element: T): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection, which aren't already in this set. The returned set preserves the element iteration order of the original set. ``` operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Set((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element) if it isn't already in this set. ``` fun <T> Set<T>.plusElement(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- #### [AbstractMutableSet](../-abstract-mutable-set/index) Provides a skeletal implementation of the [MutableSet](index#kotlin.collections.MutableSet) interface. **Platform and version requirements:** ``` abstract class AbstractMutableSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableSet<E> :      MutableSet<E>,     AbstractSet<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableSet<E> :      AbstractMutableCollection<E>,     MutableSet<E> ``` #### [HashSet](../-hash-set/index) The implementation of the [MutableSet](index#kotlin.collections.MutableSet) interface, backed by a [HashMap](../-hash-map/index#kotlin.collections.HashMap) instance. **Platform and version requirements:** ``` class HashSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` typealias HashSet<E> = HashSet<E> ``` **Platform and version requirements:** JS (1.1) ``` open class HashSet<E> : AbstractMutableSet<E>, MutableSet<E> ``` #### [LinkedHashSet](../-linked-hash-set/index) The implementation of the [MutableSet](index#kotlin.collections.MutableSet) interface, backed by a [LinkedHashMap](../-linked-hash-map/index#kotlin.collections.LinkedHashMap) instance. **Platform and version requirements:** ``` class LinkedHashSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` typealias LinkedHashSet<E> = LinkedHashSet<E> ``` **Platform and version requirements:** JS (1.1) ``` open class LinkedHashSet<E> : HashSet<E>, MutableSet<E> ```
programming_docs
kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableSet](index) / <add> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun add(element: E): Boolean ``` Adds the specified element to the set. **Return** `true` if the element has been added, `false` if the element is already contained in the set. kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableSet](index) / <remove> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun remove(element: E): Boolean ``` Removes a single instance of the specified element from this collection, if it is present. **Return** `true` if the element has been successfully removed; `false` if it was not present in the collection. kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableSet](index) / [retainAll](retain-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun retainAll(elements: Collection<E>): Boolean ``` Retains only the elements in this collection that are contained in the specified collection. **Return** `true` if any element was removed from the collection, `false` if the collection was not modified. kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableSet](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun iterator(): MutableIterator<E> ``` Returns an iterator over the elements of this object. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableSet](index) / [removeAll](remove-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun removeAll(elements: Collection<E>): Boolean ``` Removes all of this collection's elements that are also contained in the specified collection. **Return** `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableSet](index) / <clear> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun clear() ``` Removes all elements from this collection. kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableSet](index) / [addAll](add-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun addAll(elements: Collection<E>): Boolean ``` Adds all of the elements of the specified collection to this collection. **Return** `true` if any of the specified elements was added to the collection, `false` if the collection was not modified. kotlin MutableList MutableList =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface MutableList<E> : List<E>, MutableCollection<E> ``` A generic ordered collection of elements that supports adding and removing elements. Parameters ---------- `E` - the type of elements contained in the list. The mutable list is invariant in its element type. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <add> Adds the specified element to the end of this list. ``` abstract fun add(element: E): Boolean ``` Inserts an element into the list at the specified [index](add#kotlin.collections.MutableList%24add(kotlin.Int,%20kotlin.collections.MutableList.E)/index). ``` abstract fun add(index: Int, element: E) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](add-all) Adds all of the elements of the specified collection to the end of this list. ``` abstract fun addAll(elements: Collection<E>): Boolean ``` Inserts all of the elements of the specified collection [elements](add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/elements) into this list at the specified [index](add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/index). ``` abstract fun addAll(     index: Int,     elements: Collection<E> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <clear> Removes all elements from this collection. ``` abstract fun clear() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [listIterator](list-iterator) Returns a list iterator over the elements in this list (in proper sequence). ``` abstract fun listIterator(): MutableListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence), starting at the specified [index](../-list/list-iterator#kotlin.collections.List%24listIterator(kotlin.Int)/index). ``` abstract fun listIterator(index: Int): MutableListIterator<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <remove> Removes a single instance of the specified element from this collection, if it is present. ``` abstract fun remove(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` abstract fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAt](remove-at) Removes an element at the specified [index](remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)/index) from the list. ``` abstract fun removeAt(index: Int): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` abstract fun retainAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Replaces the element at the specified position in this list with the specified element. ``` abstract operator fun set(index: Int, element: E): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subList](sub-list) Returns a view of the portion of this list between the specified [fromIndex](../-list/sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/fromIndex) (inclusive) and [toIndex](../-list/sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/toIndex) (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. ``` abstract fun subList(     fromIndex: Int,     toIndex: Int ): MutableList<E> ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../last-index) Returns the index of the last item in the list or -1 if the list is empty. ``` val <T> List<T>.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asReversed](../as-reversed) Returns a reversed mutable view of the original mutable List. All changes made in the original list will be reflected in the reversed one and vice versa. ``` fun <T> MutableList<T>.asReversed(): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearch](../binary-search) Searches this list or its range for the provided [element](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for an element for which the given [comparison](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearchBy](../binary-search-by) Searches this list or its range for an element having the key returned by the specified [selector](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. ``` fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     selector: (T) -> K? ): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../component1) Returns 1st *element* from the list. ``` operator fun <T> List<T>.component1(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../component2) Returns 2nd *element* from the list. ``` operator fun <T> List<T>.component2(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../component3) Returns 3rd *element* from the list. ``` operator fun <T> List<T>.component3(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../component4) Returns 4th *element* from the list. ``` operator fun <T> List<T>.component4(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../component5) Returns 5th *element* from the list. ``` operator fun <T> List<T>.component5(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](../drop-last) Returns a list containing all elements except last [n](../drop-last#kotlin.collections%24dropLast(kotlin.collections.List((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](../drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](../drop-last-while#kotlin.collections%24dropLastWhile(kotlin.collections.List((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](../fold-right) Accumulates value starting with [initial](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](../fold-right-indexed) Accumulates value starting with [initial](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns an element at the given [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](../get-or-null) Returns an element at the given [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.getOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` ``` fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](../reduce-right) Accumulates value starting with the last element and applying [operation](../reduce-right#kotlin.collections%24reduceRight(kotlin.collections.List((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](../reduce-right-indexed) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](../reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](../reduce-right-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.collections.List((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes the element at the specified [index](../remove#kotlin.collections%24remove(kotlin.collections.MutableList((kotlin.collections.remove.T)),%20kotlin.Int)/index) from this list. In Kotlin one should use the [MutableList.removeAt](remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)) function instead. ``` fun <T> MutableList<T>.remove(index: Int): T ``` Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all elements from this [MutableList](index#kotlin.collections.MutableList) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableList((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirst](../remove-first) Removes the first element from this mutable list and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeFirst(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirstOrNull](../remove-first-or-null) Removes the first element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeFirstOrNull(): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLast](../remove-last) Removes the last element from this mutable list and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeLast(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLastOrNull](../remove-last-or-null) Removes the last element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeLastOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only elements of this [MutableList](index#kotlin.collections.MutableList) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableList((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffle](../shuffle) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) Randomly shuffles elements in this list in-place using the specified [random](../shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> MutableList<T>.shuffle(random: Random) ``` **Platform and version requirements:** JVM (1.2) Randomly shuffles elements in this mutable list using the specified [random](../shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20java.util.Random)/random) instance as the source of randomness. ``` fun <T> MutableList<T>.shuffle(random: Random) ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [slice](../slice) Returns a list containing elements at indices in the specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` Returns a list containing elements at specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` **Platform and version requirements:** JVM (1.0) #### [sort](../sort) ``` fun <T> MutableList<T>.sort(comparator: Comparator<in T>) ``` ``` fun <T> MutableList<T>.sort(comparison: (T, T) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortBy](../sort-by) Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector](../sort-by#kotlin.collections%24sortBy(kotlin.collections.MutableList((kotlin.collections.sortBy.T)),%20kotlin.Function1((kotlin.collections.sortBy.T,%20kotlin.collections.sortBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortBy(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortByDescending](../sort-by-descending) Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector](../sort-by-descending#kotlin.collections%24sortByDescending(kotlin.collections.MutableList((kotlin.collections.sortByDescending.T)),%20kotlin.Function1((kotlin.collections.sortByDescending.T,%20kotlin.collections.sortByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../sort-descending) Sorts elements in the list in-place descending according to their natural sort order. ``` fun <T : Comparable<T>> MutableList<T>.sortDescending() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0) #### [sortWith](../sort-with) Sorts elements in the list in-place according to the order specified with [comparator](../sort-with#kotlin.collections%24sortWith(kotlin.collections.MutableList((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)))/comparator). ``` fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](../take-last) Returns a list containing last [n](../take-last#kotlin.collections%24takeLast(kotlin.collections.List((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](../take-last-while) Returns a list containing last elements satisfying the given [predicate](../take-last-while#kotlin.collections%24takeLastWhile(kotlin.collections.List((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- #### [AbstractMutableList](../-abstract-mutable-list/index) Provides a skeletal implementation of the [MutableList](index#kotlin.collections.MutableList) interface. **Platform and version requirements:** ``` abstract class AbstractMutableList<E> : MutableList<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableList<E> :      MutableList<E>,     AbstractList<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableList<E> :      AbstractMutableCollection<E>,     MutableList<E> ``` #### [ArrayList](../-array-list/index) Provides a [MutableList](index#kotlin.collections.MutableList) implementation, which uses a resizable array as its backing storage. **Platform and version requirements:** ``` class ArrayList<E> : MutableList<E>, RandomAccess ``` **Platform and version requirements:** JVM (1.1) ``` typealias ArrayList<E> = ArrayList<E> ``` **Platform and version requirements:** JS (1.1) ``` open class ArrayList<E> :      AbstractMutableList<E>,     MutableList<E>,     RandomAccess ```
programming_docs
kotlin listIterator listIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / [listIterator](list-iterator) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun listIterator(): MutableListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun listIterator(index: Int): MutableListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence), starting at the specified [index](../-list/list-iterator#kotlin.collections.List%24listIterator(kotlin.Int)/index). kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / <add> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun add(element: E): Boolean ``` Adds the specified element to the end of this list. **Return** `true` because the list is always modified as the result of this operation. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun add(index: Int, element: E) ``` Inserts an element into the list at the specified [index](add#kotlin.collections.MutableList%24add(kotlin.Int,%20kotlin.collections.MutableList.E)/index). kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / <remove> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun remove(element: E): Boolean ``` Removes a single instance of the specified element from this collection, if it is present. **Return** `true` if the element has been successfully removed; `false` if it was not present in the collection. kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / [retainAll](retain-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun retainAll(elements: Collection<E>): Boolean ``` Retains only the elements in this collection that are contained in the specified collection. **Return** `true` if any element was removed from the collection, `false` if the collection was not modified. kotlin removeAt removeAt ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / [removeAt](remove-at) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun removeAt(index: Int): E ``` Removes an element at the specified [index](remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)/index) from the list. **Return** the element that has been removed. kotlin subList subList ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / [subList](sub-list) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun subList(     fromIndex: Int,     toIndex: Int ): MutableList<E> ``` Returns a view of the portion of this list between the specified [fromIndex](../-list/sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/fromIndex) (inclusive) and [toIndex](../-list/sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/toIndex) (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. Structural changes in the base list make the behavior of the view undefined. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / [removeAll](remove-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun removeAll(elements: Collection<E>): Boolean ``` Removes all of this collection's elements that are also contained in the specified collection. **Return** `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / <clear> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun clear() ``` Removes all elements from this collection. kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / [addAll](add-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun addAll(elements: Collection<E>): Boolean ``` Adds all of the elements of the specified collection to the end of this list. The elements are appended in the order they appear in the [elements](add-all#kotlin.collections.MutableList%24addAll(kotlin.collections.Collection((kotlin.collections.MutableList.E)))/elements) collection. **Return** `true` if the list was changed as the result of the operation. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun addAll(     index: Int,     elements: Collection<E> ): Boolean ``` Inserts all of the elements of the specified collection [elements](add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/elements) into this list at the specified [index](add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/index). **Return** `true` if the list was changed as the result of the operation. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableList](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract operator fun set(index: Int, element: E): E ``` Replaces the element at the specified position in this list with the specified element. **Return** the element previously at the specified position. kotlin IntIterator IntIterator =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [IntIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class IntIterator : Iterator<Int> ``` An iterator over a sequence of values of type `Int`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An iterator over a sequence of values of type `Int`. ``` IntIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` fun next(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextInt](next-int) Returns the next value in the sequence without boxing. ``` abstract fun nextInt(): Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin nextInt nextInt ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [IntIterator](index) / [nextInt](next-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun nextInt(): Int ``` Returns the next value in the sequence without boxing. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [IntIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` IntIterator() ``` An iterator over a sequence of values of type `Int`. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [IntIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun next(): Int ``` kotlin computeNext computeNext =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractIterator](index) / [computeNext](compute-next) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected abstract fun computeNext() ``` Computes the next item in the iterator. This callback method should call one of these two methods: * [setNext](set-next) with the next value of the iteration * <done> to indicate there are no more elements Failure to call either method will result in the iteration terminating with a failed state kotlin AbstractIterator AbstractIterator ================ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class AbstractIterator<T> : Iterator<T> ``` A base class to simplify implementing iterators so that implementations only have to implement [computeNext](compute-next) to implement the iterator, calling <done> when the iteration is complete. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) A base class to simplify implementing iterators so that implementations only have to implement [computeNext](compute-next) to implement the iterator, calling <done> when the iteration is complete. ``` AbstractIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [computeNext](compute-next) Computes the next item in the iterator. ``` abstract fun computeNext() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <done> Sets the state to done so that the iteration terminates. ``` fun done() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hasNext](has-next) ``` open fun hasNext(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` open fun next(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [setNext](set-next) Sets the next value in the iteration, called from the [computeNext](compute-next) function ``` fun setNext(value: T) ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin done done ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractIterator](index) / <done> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected fun done() ``` Sets the state to done so that the iteration terminates. kotlin setNext setNext ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractIterator](index) / [setNext](set-next) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected fun setNext(value: T) ``` Sets the next value in the iteration, called from the [computeNext](compute-next) function kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` AbstractIterator() ``` A base class to simplify implementing iterators so that implementations only have to implement [computeNext](compute-next) to implement the iterator, calling <done> when the iteration is complete. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun next(): T ``` kotlin hasNext hasNext ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractIterator](index) / [hasNext](has-next) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun hasNext(): Boolean ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / <contains> **Platform and version requirements:** ``` open fun contains(element: @UnsafeVariance E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun contains(element: E): Boolean ``` kotlin AbstractMutableList AbstractMutableList =================== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) **Platform and version requirements:** ``` abstract class AbstractMutableList<E> : MutableList<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableList<E> :      MutableList<E>,     AbstractList<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableList<E> :      AbstractMutableCollection<E>,     MutableList<E> ``` Provides a skeletal implementation of the [MutableList](../-mutable-list/index#kotlin.collections.MutableList) interface. Parameters ---------- `E` - the type of elements contained in the list. The list is invariant in its element type. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0) #### [<init>](-init-) Provides a skeletal implementation of the [MutableList](../-mutable-list/index#kotlin.collections.MutableList) interface. ``` <init>() ``` Properties ---------- **Platform and version requirements:** JS (1.1) #### [modCount](mod-count) ``` var modCount: Int ``` Inherited Properties -------------------- **Platform and version requirements:** #### [size](../-abstract-mutable-collection/size) ``` abstract val size: Int ``` Functions --------- #### <add> **Platform and version requirements:** JS (1.1) Adds the specified element to the end of this list. ``` open fun add(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.1) Inserts an element into the list at the specified [index](add#kotlin.collections.AbstractMutableList%24add(kotlin.Int,%20kotlin.collections.AbstractMutableList.E)/index). ``` abstract fun add(index: Int, element: E) ``` #### [addAll](add-all) **Platform and version requirements:** ``` open fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) Inserts all of the elements of the specified collection [elements](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/elements) into this list at the specified [index](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/index). ``` open fun addAll(index: Int, elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.0) #### <clear> Removes all elements from this collection. ``` open fun clear() ``` **Platform and version requirements:** JS (1.0) #### <contains> ``` open fun contains(element: E): Boolean ``` **Platform and version requirements:** #### [containsAll](contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) #### <equals> Compares this list with another list instance with the ordered structural equality. ``` open fun equals(other: Any?): Boolean ``` **Platform and version requirements:** JS (1.1) #### [hashCode](hash-code) Returns the hash code value for this list. ``` open fun hashCode(): Int ``` **Platform and version requirements:** JS (1.0) #### [indexOf](index-of) Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. ``` open fun indexOf(element: E): Int ``` **Platform and version requirements:** #### [isEmpty](is-empty) ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JS (1.0) #### <iterator> ``` open fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** JS (1.0) #### [lastIndexOf](last-index-of) Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. ``` open fun lastIndexOf(element: E): Int ``` **Platform and version requirements:** JS (1.0) #### [listIterator](list-iterator) Returns a list iterator over the elements in this list (in proper sequence). ``` open fun listIterator(): MutableListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence), starting at the specified [index](../-list/list-iterator#kotlin.collections.List%24listIterator(kotlin.Int)/index). ``` open fun listIterator(index: Int): MutableListIterator<E> ``` **Platform and version requirements:** #### <remove> ``` open fun remove(element: E): Boolean ``` **Platform and version requirements:** JS (1.0) #### [removeAll](remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` open fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [removeAt](remove-at) Removes an element at the specified [index](remove-at#kotlin.collections.AbstractMutableList%24removeAt(kotlin.Int)/index) from the list. ``` abstract fun removeAt(index: Int): E ``` **Platform and version requirements:** JS (1.1) #### [removeRange](remove-range) Removes the range of elements from this list starting from [fromIndex](remove-range#kotlin.collections.AbstractMutableList%24removeRange(kotlin.Int,%20kotlin.Int)/fromIndex) and ending with but not including [toIndex](remove-range#kotlin.collections.AbstractMutableList%24removeRange(kotlin.Int,%20kotlin.Int)/toIndex). ``` open fun removeRange(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JS (1.0) #### [retainAll](retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` open fun retainAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### <set> Replaces the element at the specified position in this list with the specified element. ``` abstract fun set(index: Int, element: E): E ``` **Platform and version requirements:** JS (1.0) #### [subList](sub-list) Returns a view of the portion of this list between the specified [fromIndex](../-list/sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/fromIndex) (inclusive) and [toIndex](../-list/sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/toIndex) (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. ``` open fun subList(     fromIndex: Int,     toIndex: Int ): MutableList<E> ``` Inherited Functions ------------------- **Platform and version requirements:** #### [containsAll](../-abstract-mutable-collection/contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [isEmpty](../-abstract-mutable-collection/is-empty) ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JS (1.1) #### [toJSON](../-abstract-mutable-collection/to-j-s-o-n) ``` fun toJSON(): Any ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../last-index) Returns the index of the last item in the list or -1 if the list is empty. ``` val <T> List<T>.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearch](../binary-search) Searches this list or its range for the provided [element](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for an element for which the given [comparison](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearchBy](../binary-search-by) Searches this list or its range for an element having the key returned by the specified [selector](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. ``` fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     selector: (T) -> K? ): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../component1) Returns 1st *element* from the list. ``` operator fun <T> List<T>.component1(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../component2) Returns 2nd *element* from the list. ``` operator fun <T> List<T>.component2(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../component3) Returns 3rd *element* from the list. ``` operator fun <T> List<T>.component3(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../component4) Returns 4th *element* from the list. ``` operator fun <T> List<T>.component4(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../component5) Returns 5th *element* from the list. ``` operator fun <T> List<T>.component5(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](../drop-last) Returns a list containing all elements except last [n](../drop-last#kotlin.collections%24dropLast(kotlin.collections.List((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](../drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](../drop-last-while#kotlin.collections%24dropLastWhile(kotlin.collections.List((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](../fold-right) Accumulates value starting with [initial](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](../fold-right-indexed) Accumulates value starting with [initial](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns an element at the given [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](../get-or-null) Returns an element at the given [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.getOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` ``` fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](../reduce-right) Accumulates value starting with the last element and applying [operation](../reduce-right#kotlin.collections%24reduceRight(kotlin.collections.List((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](../reduce-right-indexed) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](../reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](../reduce-right-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.collections.List((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` Removes the element at the specified [index](../remove#kotlin.collections%24remove(kotlin.collections.MutableList((kotlin.collections.remove.T)),%20kotlin.Int)/index) from this list. In Kotlin one should use the [MutableList.removeAt](../-mutable-list/remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)) function instead. ``` fun <T> MutableList<T>.remove(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` Removes all elements from this [MutableList](../-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableList((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirst](../remove-first) Removes the first element from this mutable list and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeFirst(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeFirstOrNull](../remove-first-or-null) Removes the first element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeFirstOrNull(): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLast](../remove-last) Removes the last element from this mutable list and returns that removed element, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if this list is empty. ``` fun <T> MutableList<T>.removeLast(): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [removeLastOrNull](../remove-last-or-null) Removes the last element from this mutable list and returns that removed element, or returns `null` if this list is empty. ``` fun <T> MutableList<T>.removeLastOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` Retains only elements of this [MutableList](../-mutable-list/index#kotlin.collections.MutableList) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableList((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableList<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffle](../shuffle) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) Randomly shuffles elements in this list in-place using the specified [random](../shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> MutableList<T>.shuffle(random: Random) ``` **Platform and version requirements:** JVM (1.2) Randomly shuffles elements in this mutable list using the specified [random](../shuffle#kotlin.collections%24shuffle(kotlin.collections.MutableList((kotlin.collections.shuffle.T)),%20java.util.Random)/random) instance as the source of randomness. ``` fun <T> MutableList<T>.shuffle(random: Random) ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [slice](../slice) Returns a list containing elements at indices in the specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` Returns a list containing elements at specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` **Platform and version requirements:** JVM (1.0) #### [sort](../sort) ``` fun <T> MutableList<T>.sort(comparator: Comparator<in T>) ``` ``` fun <T> MutableList<T>.sort(comparison: (T, T) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortBy](../sort-by) Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector](../sort-by#kotlin.collections%24sortBy(kotlin.collections.MutableList((kotlin.collections.sortBy.T)),%20kotlin.Function1((kotlin.collections.sortBy.T,%20kotlin.collections.sortBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortBy(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortByDescending](../sort-by-descending) Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector](../sort-by-descending#kotlin.collections%24sortByDescending(kotlin.collections.MutableList((kotlin.collections.sortByDescending.T)),%20kotlin.Function1((kotlin.collections.sortByDescending.T,%20kotlin.collections.sortByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(     selector: (T) -> R?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0) #### [sortWith](../sort-with) Sorts elements in the list in-place according to the order specified with [comparator](../sort-with#kotlin.collections%24sortWith(kotlin.collections.MutableList((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)))/comparator). ``` fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](../take-last) Returns a list containing last [n](../take-last#kotlin.collections%24takeLast(kotlin.collections.List((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](../take-last-while) Returns a list containing last elements satisfying the given [predicate](../take-last-while#kotlin.collections%24takeLastWhile(kotlin.collections.List((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [ArrayDeque](../-array-deque/index) Resizable-array implementation of the deque data structure. ``` class ArrayDeque<E> : AbstractMutableList<E> ``` #### [ArrayList](../-array-list/index) Provides a [MutableList](../-mutable-list/index#kotlin.collections.MutableList) implementation, which uses a resizable array as its backing storage. **Platform and version requirements:** ``` class ArrayList<E> : MutableList<E>, RandomAccess ``` **Platform and version requirements:** JVM (1.1) ``` typealias ArrayList<E> = ArrayList<E> ``` **Platform and version requirements:** JS (1.1) ``` open class ArrayList<E> :      AbstractMutableList<E>,     MutableList<E>,     RandomAccess ```
programming_docs
kotlin modCount modCount ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [modCount](mod-count) **Platform and version requirements:** JS (1.1) ``` protected var modCount: Int ``` kotlin listIterator listIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [listIterator](list-iterator) **Platform and version requirements:** JS (1.0) ``` open fun listIterator(): MutableListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence). **Platform and version requirements:** JS (1.0) ``` open fun listIterator(index: Int): MutableListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence), starting at the specified [index](../-list/list-iterator#kotlin.collections.List%24listIterator(kotlin.Int)/index). kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / <add> **Platform and version requirements:** JS (1.0) ``` open fun add(element: E): Boolean ``` Adds the specified element to the end of this list. **Return** `true` because the list is always modified as the result of this operation. **Platform and version requirements:** JVM (1.0), JS (1.0) ``` abstract fun add(index: Int, element: E) ``` ##### For JVM Inserts an element into the list at the specified [index](add#kotlin.collections.AbstractMutableList%24add(kotlin.Int,%20kotlin.collections.AbstractMutableList.E)/index). This method is redeclared as abstract, because it's not implemented in the base class, so it must be always overridden in the concrete mutable collection implementation. ##### For JS Inserts an element into the list at the specified [index](../-mutable-list/add#kotlin.collections.MutableList%24add(kotlin.Int,%20kotlin.collections.MutableList.E)/index). kotlin removeRange removeRange =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [removeRange](remove-range) **Platform and version requirements:** JS (1.1) ``` protected open fun removeRange(fromIndex: Int, toIndex: Int) ``` Removes the range of elements from this list starting from [fromIndex](remove-range#kotlin.collections.AbstractMutableList%24removeRange(kotlin.Int,%20kotlin.Int)/fromIndex) and ending with but not including [toIndex](remove-range#kotlin.collections.AbstractMutableList%24removeRange(kotlin.Int,%20kotlin.Int)/toIndex). kotlin lastIndexOf lastIndexOf =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [lastIndexOf](last-index-of) **Platform and version requirements:** ``` open fun lastIndexOf(element: @UnsafeVariance E): Int ``` **Platform and version requirements:** JS (1.1) ``` open fun lastIndexOf(element: E): Int ``` Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / <remove> **Platform and version requirements:** ``` open fun remove(element: E): Boolean ``` kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [retainAll](retain-all) **Platform and version requirements:** JS (1.1) ``` open fun retainAll(elements: Collection<E>): Boolean ``` Retains only the elements in this collection that are contained in the specified collection. **Return** `true` if any element was removed from the collection, `false` if the collection was not modified. kotlin removeAt removeAt ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [removeAt](remove-at) **Platform and version requirements:** JVM (1.0), JS (1.1) ``` abstract fun removeAt(index: Int): E ``` ##### For JVM Removes an element at the specified [index](remove-at#kotlin.collections.AbstractMutableList%24removeAt(kotlin.Int)/index) from the list. This method is redeclared as abstract, because it's not implemented in the base class, so it must be always overridden in the concrete mutable collection implementation. **Return** the element that has been removed. ##### For JS Removes an element at the specified [index](../-mutable-list/remove-at#kotlin.collections.MutableList%24removeAt(kotlin.Int)/index) from the list. **Return** the element that has been removed. kotlin subList subList ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [subList](sub-list) **Platform and version requirements:** JS (1.1) ``` open fun subList(     fromIndex: Int,     toIndex: Int ): MutableList<E> ``` Returns a view of the portion of this list between the specified [fromIndex](../-list/sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/fromIndex) (inclusive) and [toIndex](../-list/sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/toIndex) (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. Structural changes in the base list make the behavior of the view undefined. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [hashCode](hash-code) **Platform and version requirements:** JS (1.1) ``` open fun hashCode(): Int ``` Returns the hash code value for this list. kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / <iterator> **Platform and version requirements:** JS (1.1) ``` open fun iterator(): MutableIterator<E> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1) ``` protected <init>() ``` Provides a skeletal implementation of the [MutableList](../-mutable-list/index#kotlin.collections.MutableList) interface. Parameters ---------- `E` - the type of elements contained in the list. The list is invariant in its element type. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [removeAll](remove-all) **Platform and version requirements:** JS (1.1) ``` open fun removeAll(elements: Collection<E>): Boolean ``` Removes all of this collection's elements that are also contained in the specified collection. **Return** `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / <equals> **Platform and version requirements:** JS (1.1) ``` open fun equals(other: Any?): Boolean ``` Compares this list with another list instance with the ordered structural equality. **Return** true, if [other](equals#kotlin.collections.AbstractMutableList%24equals(kotlin.Any?)/other) instance is a [List](../-list/index#kotlin.collections.List) of the same size, which contains the same elements in the same order. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / <clear> **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` Removes all elements from this collection. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [containsAll](contains-all) **Platform and version requirements:** ``` open fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` open fun isEmpty(): Boolean ``` kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [addAll](add-all) **Platform and version requirements:** ``` open fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.0) ``` open fun addAll(index: Int, elements: Collection<E>): Boolean ``` Inserts all of the elements of the specified collection [elements](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/elements) into this list at the specified [index](../-mutable-list/add-all#kotlin.collections.MutableList%24addAll(kotlin.Int,%20kotlin.collections.Collection((kotlin.collections.MutableList.E)))/index). **Return** `true` if the list was changed as the result of the operation. kotlin indexOf indexOf ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / [indexOf](index-of) **Platform and version requirements:** ``` open fun indexOf(element: @UnsafeVariance E): Int ``` **Platform and version requirements:** JS (1.1) ``` open fun indexOf(element: E): Int ``` Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMutableList](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.1) ``` abstract fun set(index: Int, element: E): E ``` ##### For JVM Replaces the element at the specified position in this list with the specified element. This method is redeclared as abstract, because it's not implemented in the base class, so it must be always overridden in the concrete mutable collection implementation. **Return** the element previously at the specified position. ##### For JS Replaces the element at the specified position in this list with the specified element. **Return** the element previously at the specified position. kotlin MutableCollection MutableCollection ================= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableCollection](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface MutableCollection<E> :      Collection<E>,     MutableIterable<E> ``` A generic collection of elements that supports adding and removing elements. Parameters ---------- `E` - the type of elements contained in the collection. The mutable collection is invariant in its element type. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <add> Adds the specified element to the collection. ``` abstract fun add(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](add-all) Adds all of the elements of the specified collection to this collection. ``` abstract fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <clear> Removes all elements from this collection. ``` abstract fun clear() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns an iterator over the elements of this object. ``` abstract fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <remove> Removes a single instance of the specified element from this collection, if it is present. ``` abstract fun remove(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` abstract fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` abstract fun retainAll(elements: Collection<E>): Boolean ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns this Collection if it's not `null` and the empty list otherwise. ``` fun <T> Collection<T>?.orEmpty(): Collection<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- #### [AbstractMutableCollection](../-abstract-mutable-collection/index) Provides a skeletal implementation of the [MutableCollection](index#kotlin.collections.MutableCollection) interface. **Platform and version requirements:** ``` abstract class AbstractMutableCollection<E> :      MutableCollection<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableCollection<E> :      MutableCollection<E>,     AbstractCollection<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableCollection<E> :      AbstractCollection<E>,     MutableCollection<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableList](../-mutable-list/index) A generic ordered collection of elements that supports adding and removing elements. ``` interface MutableList<E> : List<E>, MutableCollection<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableSet](../-mutable-set/index) A generic unordered collection of elements that does not support duplicate elements, and supports adding and removing elements. ``` interface MutableSet<E> : Set<E>, MutableCollection<E> ```
programming_docs
kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableCollection](index) / <add> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun add(element: E): Boolean ``` Adds the specified element to the collection. **Return** `true` if the element has been added, `false` if the collection does not support duplicates and the element is already contained in the collection. kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableCollection](index) / <remove> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun remove(element: E): Boolean ``` Removes a single instance of the specified element from this collection, if it is present. **Return** `true` if the element has been successfully removed; `false` if it was not present in the collection. kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableCollection](index) / [retainAll](retain-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun retainAll(elements: Collection<E>): Boolean ``` Retains only the elements in this collection that are contained in the specified collection. **Return** `true` if any element was removed from the collection, `false` if the collection was not modified. kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableCollection](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun iterator(): MutableIterator<E> ``` Returns an iterator over the elements of this object. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableCollection](index) / [removeAll](remove-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun removeAll(elements: Collection<E>): Boolean ``` Removes all of this collection's elements that are also contained in the specified collection. **Return** `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableCollection](index) / <clear> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun clear() ``` Removes all elements from this collection. kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableCollection](index) / [addAll](add-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun addAll(elements: Collection<E>): Boolean ``` Adds all of the elements of the specified collection to this collection. **Return** `true` if any of the specified elements was added to the collection, `false` if the collection was not modified. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / <size> **Platform and version requirements:** ``` val size: Int ``` **Platform and version requirements:** JS (1.1) ``` open val size: Int ``` Returns the number of key/value pairs in the map. kotlin values values ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / <values> **Platform and version requirements:** ``` val values: MutableCollection<V> ``` kotlin LinkedHashMap LinkedHashMap ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) **Platform and version requirements:** ``` class LinkedHashMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` typealias LinkedHashMap<K, V> = LinkedHashMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` open class LinkedHashMap<K, V> :      HashMap<K, V>,     MutableMap<K, V> ``` Hash table based implementation of the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface, which additionally preserves the insertion order of entries during the iteration. The insertion order is preserved by maintaining a doubly-linked list of all of its entries. Constructors ------------ **Platform and version requirements:** JS (1.0) #### [<init>](-init-) Constructs an empty [LinkedHashMap](index#kotlin.collections.LinkedHashMap) instance. ``` <init>() ``` ``` <init>(initialCapacity: Int, loadFactor: Float) ``` ``` <init>(initialCapacity: Int) ``` Constructs an instance of [LinkedHashMap](index#kotlin.collections.LinkedHashMap) filled with the contents of the specified original map. ``` <init>(original: Map<out K, V>) ``` Properties ---------- **Platform and version requirements:** #### <entries> ``` val entries: MutableSet<MutableEntry<K, V>> ``` **Platform and version requirements:** #### <keys> ``` val keys: MutableSet<K> ``` #### <size> Returns the number of key/value pairs in the map. **Platform and version requirements:** ``` val size: Int ``` **Platform and version requirements:** JS (1.1) ``` open val size: Int ``` **Platform and version requirements:** #### <values> ``` val values: MutableCollection<V> ``` Inherited Properties -------------------- **Platform and version requirements:** #### [keys](../-hash-map/keys) ``` val keys: MutableSet<K> ``` **Platform and version requirements:** #### [values](../-hash-map/values) ``` val values: MutableCollection<V> ``` Functions --------- #### <clear> Removes all elements from this map. **Platform and version requirements:** ``` fun clear() ``` **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` #### [containsKey](contains-key) Returns `true` if the map contains the specified [key](../-map/contains-key#kotlin.collections.Map%24containsKey(kotlin.collections.Map.K)/key). **Platform and version requirements:** ``` fun containsKey(key: K): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun containsKey(key: K): Boolean ``` #### [containsValue](contains-value) Returns `true` if the map maps one or more keys to the specified [value](../-map/contains-value#kotlin.collections.Map%24containsValue(kotlin.collections.Map.V)/value). **Platform and version requirements:** ``` fun containsValue(value: V): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun containsValue(value: V): Boolean ``` #### <get> Returns the value corresponding to the given [key](../-map/get#kotlin.collections.Map%24get(kotlin.collections.Map.K)/key), or `null` if such a key is not present in the map. **Platform and version requirements:** ``` fun get(key: K): V? ``` **Platform and version requirements:** JS (1.1) ``` open operator fun get(key: K): V? ``` **Platform and version requirements:** #### [isEmpty](is-empty) ``` fun isEmpty(): Boolean ``` #### <put> Associates the specified [value](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/value) with the specified [key](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/key) in the map. **Platform and version requirements:** ``` fun put(key: K, value: V): V? ``` **Platform and version requirements:** JS (1.1) ``` open fun put(key: K, value: V): V? ``` **Platform and version requirements:** #### [putAll](put-all) ``` fun putAll(from: Map<out K, V>) ``` #### <remove> Removes the specified key and its corresponding value from this map. **Platform and version requirements:** ``` fun remove(key: K): V? ``` **Platform and version requirements:** JS (1.1) ``` open fun remove(key: K): V? ``` Inherited Functions ------------------- **Platform and version requirements:** #### [isEmpty](../-hash-map/is-empty) ``` fun isEmpty(): Boolean ``` **Platform and version requirements:** #### [putAll](../-hash-map/put-all) ``` fun putAll(from: Map<out K, V>) ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all entries match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Map((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.all(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if map has at least one entry. ``` fun <K, V> Map<out K, V>.any(): Boolean ``` Returns `true` if at least one entry matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Map((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.any(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Creates an [Iterable](../-iterable/index#kotlin.collections.Iterable) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Checks if the map contains the given key. ``` operator fun <K, V> Map<out K, V>.contains(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](../contains-key) Returns `true` if the map contains the specified [key](../contains-key#kotlin.collections%24containsKey(kotlin.collections.Map((kotlin.collections.containsKey.K,%20kotlin.Any?)),%20kotlin.collections.containsKey.K)/key). ``` fun <K> Map<out K, *>.containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](../contains-value) Returns `true` if the map maps one or more keys to the specified [value](../contains-value#kotlin.collections%24containsValue(kotlin.collections.Map((kotlin.collections.containsValue.K,%20kotlin.collections.containsValue.V)),%20kotlin.collections.containsValue.V)/value). ``` fun <K, V> Map<K, V>.containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of entries in this map. ``` fun <K, V> Map<out K, V>.count(): Int ``` Returns the number of entries matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Map((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.count(     predicate: (Entry<K, V>) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a new map containing all key-value pairs matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Map((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filter(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterKeys](../filter-keys) Returns a map containing all key-value pairs with keys matching the given [predicate](../filter-keys#kotlin.collections%24filterKeys(kotlin.collections.Map((kotlin.collections.filterKeys.K,%20kotlin.collections.filterKeys.V)),%20kotlin.Function1((kotlin.collections.filterKeys.K,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterKeys(     predicate: (K) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a new map containing all key-value pairs not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Map((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterNot(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all entries not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/predicate) into the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/destination). ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all entries matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/predicate) into the mutable map given as [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/destination) parameter. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterValues](../filter-values) Returns a map containing all key-value pairs with values matching the given [predicate](../filter-values#kotlin.collections%24filterValues(kotlin.collections.Map((kotlin.collections.filterValues.K,%20kotlin.collections.filterValues.V)),%20kotlin.Function1((kotlin.collections.filterValues.V,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterValues(     predicate: (V) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Map((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to entries of this map in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOf(     transform: (Entry<K, V>) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Map((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to entries of this map in iteration order, or `null` if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOfOrNull(     transform: (Entry<K, V>) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Iterable<R> ): List<R> ``` ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each entry of original map, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Iterable<R> ): C ``` ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Map((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Unit)))/action) on each entry. ``` fun <K, V> Map<out K, V>.forEach(     action: (Entry<K, V>) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [get](../get) Returns the value corresponding to the given [key](../get#kotlin.collections%24get(kotlin.collections.Map((kotlin.collections.get.K,%20kotlin.collections.get.V)),%20kotlin.collections.get.K)/key), or `null` if such a key is not present in the map. ``` operator fun <K, V> Map<out K, V>.get(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns the value for the given [key](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/key) if the value is present and not `null`. Otherwise, returns the result of the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/defaultValue) function. ``` fun <K, V> Map<K, V>.getOrElse(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrPut](../get-or-put) Returns the value for the given [key](../get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/key) if the value is present and not `null`. Otherwise, calls the [defaultValue](../get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/defaultValue) function, puts its result into the map under the given key and returns the call result. ``` fun <K, V> MutableMap<K, V>.getOrPut(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [getValue](../get-value) Returns the value for the given [key](../get-value#kotlin.collections%24getValue(kotlin.collections.Map((kotlin.collections.getValue.K,%20kotlin.collections.getValue.V)),%20kotlin.collections.getValue.K)/key) or throws an exception if there is no such key in the map. ``` fun <K, V> Map<K, V>.getValue(key: K): V ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this map if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.M,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the map is empty. ``` fun <M, R> M.ifEmpty(     defaultValue: () -> R ): R where M : Map<*, *>, M : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if this map is not empty. ``` fun <K, V> Map<out K, V>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable map is either null or empty. ``` fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Map((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.collections.map.R)))/transform) function to each entry in the original map. ``` fun <K, V, R> Map<out K, V>.map(     transform: (Entry<K, V>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeys](../map-keys) Returns a new Map with entries having the keys obtained by applying the [transform](../map-keys#kotlin.collections%24mapKeys(kotlin.collections.Map((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.collections.mapKeys.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R> Map<out K, V>.mapKeys(     transform: (Entry<K, V>) -> R ): Map<R, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeysTo](../map-keys-to) Populates the given [destination](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/destination) map with entries having the keys obtained by applying the [transform](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Map((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.collections.mapNotNull.R?)))/transform) function to each entry in the original map. ``` fun <K, V, R : Any> Map<out K, V>.mapNotNull(     transform: (Entry<K, V>) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each entry in the original map and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(     destination: C,     transform: (Entry<K, V>) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/transform) function to each entry of the original map and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(     destination: C,     transform: (Entry<K, V>) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValues](../map-values) Returns a new map with entries having the keys of this map and the values obtained by applying the [transform](../map-values#kotlin.collections%24mapValues(kotlin.collections.Map((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.collections.mapValues.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R> Map<out K, V>.mapValues(     transform: (Entry<K, V>) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValuesTo](../map-values-to) Populates the given [destination](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/destination) map with entries having the keys of this map and the values obtained by applying the [transform](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first entry yielding the largest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.maxOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first entry having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Map((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first entry having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Map((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.minOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minus](../minus) Returns a map containing all entries of the original map except the entry with the given [key](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.minus.K)/key). ``` operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.Iterable((kotlin.collections.minus.K)))/keys) collection. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Iterable<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.Array((kotlin.collections.minus.K)))/keys) array. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Array<out K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.sequences.Sequence((kotlin.collections.minus.K)))/keys) sequence. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Sequence<K> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minusAssign](../minus-assign) Removes the entry with the given [key](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.minusAssign.K)/key) from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) ``` Removes all entries the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.K)))/keys) collection from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Iterable<K>) ``` Removes all entries the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.Array((kotlin.collections.minusAssign.K)))/keys) array from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Array<out K>) ``` Removes all entries from the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.K)))/keys) sequence from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Sequence<K>) ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first entry having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Map((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first entry having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Map((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the map has no entries. ``` fun <K, V> Map<out K, V>.none(): Boolean ``` Returns `true` if no entries match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Map((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.none(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.onEach.K,%20kotlin.collections.onEach.V)),%20kotlin.Unit)))/action) on each entry and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEach(     action: (Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.M,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.Map.Entry((kotlin.collections.onEachIndexed.K,%20kotlin.collections.onEachIndexed.V)),%20kotlin.Unit)))/action) on each entry, providing sequential index with the entry, and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEachIndexed(     action: (index: Int, Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns the [Map](../-map/index#kotlin.collections.Map) if its not `null`, or the empty [Map](../-map/index#kotlin.collections.Map) otherwise. ``` fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair). ``` operator fun <K, V> Map<out K, V>.plus(     pair: Pair<K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Iterable<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Array<out Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Sequence<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from another [map](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map). ``` operator fun <K, V> Map<out K, V>.plus(     map: Map<out K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Appends or replaces the given [pair](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/pair) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pair: Pair<K, V>) ``` Appends or replaces all pairs from the given collection of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Iterable<Pair<K, V>>) ``` Appends or replaces all pairs from the given array of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Array<out Pair<K, V>>) ``` Appends or replaces all pairs from the given sequence of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Sequence<Pair<K, V>>) ``` Appends or replaces all entries from the given [map](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Map((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/map) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     map: Map<K, V>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [putAll](../put-all) Puts all the given [pairs](../put-all#kotlin.collections%24putAll(kotlin.collections.MutableMap((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)))))/pairs) into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Array<out Pair<K, V>>) ``` Puts all the elements of the given collection into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Iterable<Pair<K, V>>) ``` Puts all the elements of the given sequence into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Sequence<Pair<K, V>>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes the specified key and its corresponding value from this map. ``` fun <K, V> MutableMap<out K, V>.remove(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [set](../set) Allows to use the index operator for storing values in a mutable map. ``` operator fun <K, V> MutableMap<K, V>.set(key: K, value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [setValue](../set-value) Stores the value of the property for the given object in this mutable map. ``` operator fun <V> MutableMap<in String, in V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all key-value pairs. ``` fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMap](../to-map) Returns a new read-only map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Map((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given map. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMutableMap](../to-mutable-map) Returns a new mutable map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withDefault](../with-default) Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.Map((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> Map<K, V>.withDefault(     defaultValue: (key: K) -> V ): Map<K, V> ``` Returns a wrapper of this mutable map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.MutableMap((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> MutableMap<K, V>.withDefault(     defaultValue: (key: K) -> V ): MutableMap<K, V> ```
programming_docs
kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / <remove> **Platform and version requirements:** ``` fun remove(key: K): V? ``` **Platform and version requirements:** JS (1.1) ``` open fun remove(key: K): V? ``` Removes the specified key and its corresponding value from this map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. kotlin keys keys ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / <keys> **Platform and version requirements:** ``` val keys: MutableSet<K> ``` kotlin containsKey containsKey =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / [containsKey](contains-key) **Platform and version requirements:** ``` fun containsKey(key: K): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun containsKey(key: K): Boolean ``` Returns `true` if the map contains the specified [key](../-map/contains-key#kotlin.collections.Map%24containsKey(kotlin.collections.Map.K)/key). kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0) ``` <init>() ``` Constructs an empty [LinkedHashMap](index#kotlin.collections.LinkedHashMap) instance. **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int) ``` **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int, loadFactor: Float) ``` Constructs an empty [LinkedHashMap](index#kotlin.collections.LinkedHashMap) instance. Parameters ---------- `initialCapacity` - the initial capacity (ignored) `loadFactor` - the load factor (ignored) Exceptions ---------- `IllegalArgumentException` - if the initial capacity or load factor are negative **Platform and version requirements:** JS (1.0) ``` <init>(original: Map<out K, V>) ``` Constructs an instance of [LinkedHashMap](index#kotlin.collections.LinkedHashMap) filled with the contents of the specified original map. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / <clear> **Platform and version requirements:** ``` fun clear() ``` **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` Removes all elements from this map. kotlin entries entries ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / <entries> **Platform and version requirements:** ``` val entries: MutableSet<MutableEntry<K, V>> ``` kotlin put put === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / <put> **Platform and version requirements:** ``` fun put(key: K, value: V): V? ``` **Platform and version requirements:** JS (1.1) ``` open fun put(key: K, value: V): V? ``` Associates the specified [value](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/value) with the specified [key](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/key) in the map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` fun isEmpty(): Boolean ``` kotlin containsValue containsValue ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / [containsValue](contains-value) **Platform and version requirements:** ``` fun containsValue(value: V): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun containsValue(value: V): Boolean ``` Returns `true` if the map maps one or more keys to the specified [value](../-map/contains-value#kotlin.collections.Map%24containsValue(kotlin.collections.Map.V)/value). kotlin putAll putAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / [putAll](put-all) **Platform and version requirements:** ``` fun putAll(from: Map<out K, V>) ``` kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashMap](index) / <get> **Platform and version requirements:** ``` fun get(key: K): V? ``` **Platform and version requirements:** JS (1.1) ``` open operator fun get(key: K): V? ``` Returns the value corresponding to the given [key](../-map/get#kotlin.collections.Map%24get(kotlin.collections.Map.K)/key), or `null` if such a key is not present in the map. kotlin hasPrevious hasPrevious =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ListIterator](index) / [hasPrevious](has-previous) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun hasPrevious(): Boolean ``` Returns `true` if there are elements in the iteration before the current element. kotlin ListIterator ListIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ListIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface ListIterator<out T> : Iterator<T> ``` An iterator over a collection that supports indexed access. **See Also** [List.listIterator](../-list/list-iterator#kotlin.collections.List%24listIterator()) Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hasNext](has-next) Returns `true` if the iteration has more elements. ``` abstract fun hasNext(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hasPrevious](has-previous) Returns `true` if there are elements in the iteration before the current element. ``` abstract fun hasPrevious(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> Returns the next element in the iteration. ``` abstract fun next(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextIndex](next-index) Returns the index of the element that would be returned by a subsequent call to [next](next#kotlin.collections.ListIterator%24next()). ``` abstract fun nextIndex(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <previous> Returns the previous element in the iteration and moves the cursor position backwards. ``` abstract fun previous(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [previousIndex](previous-index) Returns the index of the element that would be returned by a subsequent call to [previous](previous#kotlin.collections.ListIterator%24previous()). ``` abstract fun previousIndex(): Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableListIterator](../-mutable-list-iterator/index) An iterator over a mutable collection that supports indexed access. Provides the ability to add, modify and remove elements while iterating. ``` interface MutableListIterator<T> :      ListIterator<T>,     MutableIterator<T> ``` kotlin previous previous ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ListIterator](index) / <previous> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun previous(): T ``` Returns the previous element in the iteration and moves the cursor position backwards. kotlin nextIndex nextIndex ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ListIterator](index) / [nextIndex](next-index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun nextIndex(): Int ``` Returns the index of the element that would be returned by a subsequent call to [next](next#kotlin.collections.ListIterator%24next()). kotlin previousIndex previousIndex ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ListIterator](index) / [previousIndex](previous-index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun previousIndex(): Int ``` Returns the index of the element that would be returned by a subsequent call to [previous](previous#kotlin.collections.ListIterator%24previous()). kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ListIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun next(): T ``` Returns the next element in the iteration. kotlin hasNext hasNext ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ListIterator](index) / [hasNext](has-next) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun hasNext(): Boolean ``` Returns `true` if the iteration has more elements. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open val size: Int ``` kotlin values values ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / <values> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open val values: Collection<V> ``` Returns a read-only [Collection](../-collection/index#kotlin.collections.Collection) of all values in this map. Accessing this property first time creates a values view from [entries](../-map/entries#kotlin.collections.Map%24entries). All subsequent accesses just return the created instance. kotlin AbstractMap AbstractMap =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` abstract class AbstractMap<K, out V> : Map<K, V> ``` Provides a skeletal implementation of the read-only [Map](../-map/index#kotlin.collections.Map) interface. The implementor is required to implement [entries](../-map/entries#kotlin.collections.Map%24entries) property, which should return read-only set of map entries. Parameters ---------- `K` - the type of map keys. The map is invariant in its key type. `V` - the type of map values. The map is covariant in its value type. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Provides a skeletal implementation of the read-only [Map](../-map/index#kotlin.collections.Map) interface. ``` AbstractMap() ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <keys> Returns a read-only [Set](../-set/index#kotlin.collections.Set) of all keys in this map. ``` open val keys: Set<K> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> ``` open val size: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <values> Returns a read-only [Collection](../-collection/index#kotlin.collections.Collection) of all values in this map. ``` open val values: Collection<V> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](contains-key) ``` open fun containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](contains-value) ``` open fun containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Compares this map with other instance with the ordered structural equality. ``` open fun equals(other: Any?): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> ``` open operator fun get(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hashCode](hash-code) Returns the hash code value for this map. ``` open fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns a string representation of the object. ``` open fun toString(): String ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all entries match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Map((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.all(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if map has at least one entry. ``` fun <K, V> Map<out K, V>.any(): Boolean ``` Returns `true` if at least one entry matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Map((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.any(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Creates an [Iterable](../-iterable/index#kotlin.collections.Iterable) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Checks if the map contains the given key. ``` operator fun <K, V> Map<out K, V>.contains(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](../contains-key) Returns `true` if the map contains the specified [key](../contains-key#kotlin.collections%24containsKey(kotlin.collections.Map((kotlin.collections.containsKey.K,%20kotlin.Any?)),%20kotlin.collections.containsKey.K)/key). ``` fun <K> Map<out K, *>.containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](../contains-value) Returns `true` if the map maps one or more keys to the specified [value](../contains-value#kotlin.collections%24containsValue(kotlin.collections.Map((kotlin.collections.containsValue.K,%20kotlin.collections.containsValue.V)),%20kotlin.collections.containsValue.V)/value). ``` fun <K, V> Map<K, V>.containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of entries in this map. ``` fun <K, V> Map<out K, V>.count(): Int ``` Returns the number of entries matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Map((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.count(     predicate: (Entry<K, V>) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a new map containing all key-value pairs matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Map((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filter(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterKeys](../filter-keys) Returns a map containing all key-value pairs with keys matching the given [predicate](../filter-keys#kotlin.collections%24filterKeys(kotlin.collections.Map((kotlin.collections.filterKeys.K,%20kotlin.collections.filterKeys.V)),%20kotlin.Function1((kotlin.collections.filterKeys.K,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterKeys(     predicate: (K) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a new map containing all key-value pairs not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Map((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterNot(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all entries not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/predicate) into the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/destination). ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all entries matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/predicate) into the mutable map given as [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/destination) parameter. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterValues](../filter-values) Returns a map containing all key-value pairs with values matching the given [predicate](../filter-values#kotlin.collections%24filterValues(kotlin.collections.Map((kotlin.collections.filterValues.K,%20kotlin.collections.filterValues.V)),%20kotlin.Function1((kotlin.collections.filterValues.V,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterValues(     predicate: (V) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Map((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to entries of this map in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOf(     transform: (Entry<K, V>) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Map((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to entries of this map in iteration order, or `null` if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOfOrNull(     transform: (Entry<K, V>) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Iterable<R> ): List<R> ``` ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each entry of original map, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Iterable<R> ): C ``` ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Map((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Unit)))/action) on each entry. ``` fun <K, V> Map<out K, V>.forEach(     action: (Entry<K, V>) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [get](../get) Returns the value corresponding to the given [key](../get#kotlin.collections%24get(kotlin.collections.Map((kotlin.collections.get.K,%20kotlin.collections.get.V)),%20kotlin.collections.get.K)/key), or `null` if such a key is not present in the map. ``` operator fun <K, V> Map<out K, V>.get(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns the value for the given [key](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/key) if the value is present and not `null`. Otherwise, returns the result of the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/defaultValue) function. ``` fun <K, V> Map<K, V>.getOrElse(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getValue](../get-value) Returns the value of the property for the given object from this read-only map. ``` operator fun <V, V1 : V> Map<in String, V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V1 ``` Returns the value for the given [key](../get-value#kotlin.collections%24getValue(kotlin.collections.Map((kotlin.collections.getValue.K,%20kotlin.collections.getValue.V)),%20kotlin.collections.getValue.K)/key) or throws an exception if there is no such key in the map. ``` fun <K, V> Map<K, V>.getValue(key: K): V ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this map if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.M,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the map is empty. ``` fun <M, R> M.ifEmpty(     defaultValue: () -> R ): R where M : Map<*, *>, M : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if this map is not empty. ``` fun <K, V> Map<out K, V>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable map is either null or empty. ``` fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) over the entries in the [Map](../-map/index#kotlin.collections.Map). ``` operator fun <K, V> Map<out K, V>.iterator(): Iterator<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Map((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.collections.map.R)))/transform) function to each entry in the original map. ``` fun <K, V, R> Map<out K, V>.map(     transform: (Entry<K, V>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeys](../map-keys) Returns a new Map with entries having the keys obtained by applying the [transform](../map-keys#kotlin.collections%24mapKeys(kotlin.collections.Map((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.collections.mapKeys.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R> Map<out K, V>.mapKeys(     transform: (Entry<K, V>) -> R ): Map<R, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeysTo](../map-keys-to) Populates the given [destination](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/destination) map with entries having the keys obtained by applying the [transform](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Map((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.collections.mapNotNull.R?)))/transform) function to each entry in the original map. ``` fun <K, V, R : Any> Map<out K, V>.mapNotNull(     transform: (Entry<K, V>) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each entry in the original map and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(     destination: C,     transform: (Entry<K, V>) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/transform) function to each entry of the original map and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(     destination: C,     transform: (Entry<K, V>) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValues](../map-values) Returns a new map with entries having the keys of this map and the values obtained by applying the [transform](../map-values#kotlin.collections%24mapValues(kotlin.collections.Map((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.collections.mapValues.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R> Map<out K, V>.mapValues(     transform: (Entry<K, V>) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValuesTo](../map-values-to) Populates the given [destination](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/destination) map with entries having the keys of this map and the values obtained by applying the [transform](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first entry yielding the largest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.maxOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first entry having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Map((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first entry having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Map((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.minOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minus](../minus) Returns a map containing all entries of the original map except the entry with the given [key](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.minus.K)/key). ``` operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.Iterable((kotlin.collections.minus.K)))/keys) collection. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Iterable<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.Array((kotlin.collections.minus.K)))/keys) array. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Array<out K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.sequences.Sequence((kotlin.collections.minus.K)))/keys) sequence. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Sequence<K> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first entry having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Map((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first entry having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Map((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the map has no entries. ``` fun <K, V> Map<out K, V>.none(): Boolean ``` Returns `true` if no entries match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Map((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.none(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.onEach.K,%20kotlin.collections.onEach.V)),%20kotlin.Unit)))/action) on each entry and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEach(     action: (Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.M,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.Map.Entry((kotlin.collections.onEachIndexed.K,%20kotlin.collections.onEachIndexed.V)),%20kotlin.Unit)))/action) on each entry, providing sequential index with the entry, and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEachIndexed(     action: (index: Int, Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns the [Map](../-map/index#kotlin.collections.Map) if its not `null`, or the empty [Map](../-map/index#kotlin.collections.Map) otherwise. ``` fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair). ``` operator fun <K, V> Map<out K, V>.plus(     pair: Pair<K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Iterable<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Array<out Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Sequence<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from another [map](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map). ``` operator fun <K, V> Map<out K, V>.plus(     map: Map<out K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all key-value pairs. ``` fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMap](../to-map) Returns a new read-only map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Map((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given map. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMutableMap](../to-mutable-map) Returns a new mutable map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withDefault](../with-default) Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.Map((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> Map<K, V>.withDefault(     defaultValue: (key: K) -> V ): Map<K, V> ``` Inheritors ---------- #### [AbstractMutableMap](../-abstract-mutable-map/index) Provides a skeletal implementation of the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface. **Platform and version requirements:** ``` abstract class AbstractMutableMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableMap<K, V> :      MutableMap<K, V>,     AbstractMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableMap<K, V> :      AbstractMap<K, V>,     MutableMap<K, V> ```
programming_docs
kotlin keys keys ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / <keys> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open val keys: Set<K> ``` Returns a read-only [Set](../-set/index#kotlin.collections.Set) of all keys in this map. Accessing this property first time creates a keys view from [entries](../-map/entries#kotlin.collections.Map%24entries). All subsequent accesses just return the created instance. kotlin containsKey containsKey =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / [containsKey](contains-key) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun containsKey(key: K): Boolean ``` kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun hashCode(): Int ``` Returns the hash code value for this map. It is the same as the hashCode of [entries](../-map/entries#kotlin.collections.Map%24entries) set. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun toString(): String ``` Returns a string representation of the object. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected AbstractMap() ``` Provides a skeletal implementation of the read-only [Map](../-map/index#kotlin.collections.Map) interface. The implementor is required to implement [entries](../-map/entries#kotlin.collections.Map%24entries) property, which should return read-only set of map entries. Parameters ---------- `K` - the type of map keys. The map is invariant in its key type. `V` - the type of map values. The map is covariant in its value type. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun equals(other: Any?): Boolean ``` Compares this map with other instance with the ordered structural equality. **Return** true, if [other](equals#kotlin.collections.AbstractMap%24equals(kotlin.Any?)/other) instance is a [Map](../-map/index#kotlin.collections.Map) of the same size, all entries of which are contained in the [entries](../-map/entries#kotlin.collections.Map%24entries) set of this map. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` kotlin containsValue containsValue ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / [containsValue](contains-value) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun containsValue(value: @UnsafeVariance V): Boolean ``` kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractMap](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open operator fun get(key: K): V? ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val size: Int ``` kotlin AbstractList AbstractList ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` abstract class AbstractList<out E> :      AbstractCollection<E>,     List<E> ``` Provides a skeletal implementation of the read-only [List](../-list/index#kotlin.collections.List) interface. This class is intended to help implementing read-only lists so it doesn't support concurrent modification tracking. Parameters ---------- `E` - the type of elements contained in the list. The list is covariant in its element type. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Provides a skeletal implementation of the read-only [List](../-list/index#kotlin.collections.List) interface. ``` AbstractList() ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> ``` abstract val size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Compares this list with other list instance with the ordered structural equality. ``` open fun equals(other: Any?): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> ``` abstract fun get(index: Int): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hashCode](hash-code) Returns the hash code value for this list. ``` open fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](index-of) ``` open fun indexOf(element: E): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> ``` open fun iterator(): Iterator<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](last-index-of) ``` open fun lastIndexOf(element: E): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [listIterator](list-iterator) ``` open fun listIterator(): ListIterator<E> ``` ``` open fun listIterator(index: Int): ListIterator<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subList](sub-list) ``` open fun subList(fromIndex: Int, toIndex: Int): List<E> ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../last-index) Returns the index of the last item in the list or -1 if the list is empty. ``` val <T> List<T>.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asReversed](../as-reversed) Returns a reversed read-only view of the original List. All changes made in the original list will be reflected in the reversed one. ``` fun <T> List<T>.asReversed(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearch](../binary-search) Searches this list or its range for the provided [element](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for an element for which the given [comparison](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearchBy](../binary-search-by) Searches this list or its range for an element having the key returned by the specified [selector](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. ``` fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     selector: (T) -> K? ): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../component1) Returns 1st *element* from the list. ``` operator fun <T> List<T>.component1(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../component2) Returns 2nd *element* from the list. ``` operator fun <T> List<T>.component2(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../component3) Returns 3rd *element* from the list. ``` operator fun <T> List<T>.component3(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../component4) Returns 4th *element* from the list. ``` operator fun <T> List<T>.component4(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../component5) Returns 5th *element* from the list. ``` operator fun <T> List<T>.component5(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](../drop-last) Returns a list containing all elements except last [n](../drop-last#kotlin.collections%24dropLast(kotlin.collections.List((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](../drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](../drop-last-while#kotlin.collections%24dropLastWhile(kotlin.collections.List((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](../fold-right) Accumulates value starting with [initial](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](../fold-right-indexed) Accumulates value starting with [initial](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns an element at the given [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](../get-or-null) Returns an element at the given [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.getOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` ``` fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](../reduce-right) Accumulates value starting with the last element and applying [operation](../reduce-right#kotlin.collections%24reduceRight(kotlin.collections.List((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](../reduce-right-indexed) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](../reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](../reduce-right-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.collections.List((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [slice](../slice) Returns a list containing elements at indices in the specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` Returns a list containing elements at specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](../take-last) Returns a list containing last [n](../take-last#kotlin.collections%24takeLast(kotlin.collections.List((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](../take-last-while) Returns a list containing last elements satisfying the given [predicate](../take-last-while#kotlin.collections%24takeLastWhile(kotlin.collections.List((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ```
programming_docs
kotlin listIterator listIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / [listIterator](list-iterator) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun listIterator(): ListIterator<E> ``` ``` open fun listIterator(index: Int): ListIterator<E> ``` kotlin lastIndexOf lastIndexOf =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / [lastIndexOf](last-index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun lastIndexOf(element: @UnsafeVariance E): Int ``` kotlin subList subList ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / [subList](sub-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun subList(fromIndex: Int, toIndex: Int): List<E> ``` kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun hashCode(): Int ``` Returns the hash code value for this list. kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun iterator(): Iterator<E> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected AbstractList() ``` Provides a skeletal implementation of the read-only [List](../-list/index#kotlin.collections.List) interface. This class is intended to help implementing read-only lists so it doesn't support concurrent modification tracking. Parameters ---------- `E` - the type of elements contained in the list. The list is covariant in its element type. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun equals(other: Any?): Boolean ``` Compares this list with other list instance with the ordered structural equality. **Return** true, if [other](equals#kotlin.collections.AbstractList%24equals(kotlin.Any?)/other) instance is a [List](../-list/index#kotlin.collections.List) of the same size, which contains the same elements in the same order. kotlin indexOf indexOf ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / [indexOf](index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun indexOf(element: @UnsafeVariance E): Int ``` kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractList](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun get(index: Int): E ``` kotlin MutableIterator MutableIterator =============== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface MutableIterator<out T> : Iterator<T> ``` An iterator over a mutable collection. Provides the ability to remove elements while iterating. **See Also** [MutableCollection.iterator](../-mutable-collection/iterator#kotlin.collections.MutableCollection%24iterator()) Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <remove> Removes from the underlying collection the last element returned by this iterator. ``` abstract fun remove() ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableListIterator](../-mutable-list-iterator/index) An iterator over a mutable collection that supports indexed access. Provides the ability to add, modify and remove elements while iterating. ``` interface MutableListIterator<T> :      ListIterator<T>,     MutableIterator<T> ``` kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableIterator](index) / <remove> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun remove() ``` Removes from the underlying collection the last element returned by this iterator. kotlin Grouping Grouping ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Grouping](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` interface Grouping<T, out K> ``` Represents a source of elements with a [keyOf](key-of) function, which can be applied to each element to get its key. A [Grouping](index) structure serves as an intermediate step in group-and-fold operations: they group elements by their keys and then fold each group with some aggregating operation. It is created by attaching `keySelector: (T) -> K` function to a source of elements. To get an instance of [Grouping](index) use one of `groupingBy` extension functions: * [Iterable.groupingBy](../grouping-by) * [Sequence.groupingBy](../../kotlin.sequences/grouping-by) * [Array.groupingBy](../grouping-by) * [CharSequence.groupingBy](../../kotlin.text/grouping-by) For the list of group-and-fold operations available, see the [extension functions](#extension-functions) for `Grouping`. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [keyOf](key-of) Extracts the key of an [element](key-of#kotlin.collections.Grouping%24keyOf(kotlin.collections.Grouping.T)/element). ``` abstract fun keyOf(element: T): K ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sourceIterator](source-iterator) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) over the elements of the source of this grouping. ``` abstract fun sourceIterator(): Iterator<T> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [aggregate](../aggregate) Groups elements from the [Grouping](index) source by key and applies [operation](../aggregate#kotlin.collections%24aggregate(kotlin.collections.Grouping((kotlin.collections.aggregate.T,%20kotlin.collections.aggregate.K)),%20kotlin.Function4((kotlin.collections.aggregate.K,%20kotlin.collections.aggregate.R?,%20kotlin.collections.aggregate.T,%20kotlin.Boolean,%20kotlin.collections.aggregate.R)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. ``` fun <T, K, R> Grouping<T, K>.aggregate(     operation: (key: K, accumulator: R?, element: T, first: Boolean) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [aggregateTo](../aggregate-to) Groups elements from the [Grouping](index) source by key and applies [operation](../aggregate-to#kotlin.collections%24aggregateTo(kotlin.collections.Grouping((kotlin.collections.aggregateTo.T,%20kotlin.collections.aggregateTo.K)),%20kotlin.collections.aggregateTo.M,%20kotlin.Function4((kotlin.collections.aggregateTo.K,%20kotlin.collections.aggregateTo.R?,%20kotlin.collections.aggregateTo.T,%20kotlin.Boolean,%20kotlin.collections.aggregateTo.R)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](../aggregate-to#kotlin.collections%24aggregateTo(kotlin.collections.Grouping((kotlin.collections.aggregateTo.T,%20kotlin.collections.aggregateTo.K)),%20kotlin.collections.aggregateTo.M,%20kotlin.Function4((kotlin.collections.aggregateTo.K,%20kotlin.collections.aggregateTo.R?,%20kotlin.collections.aggregateTo.T,%20kotlin.Boolean,%20kotlin.collections.aggregateTo.R)))/destination) map. ``` fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.aggregateTo(     destination: M,     operation: (key: K, accumulator: R?, element: T, first: Boolean) -> R ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [eachCountTo](../each-count-to) Groups elements from the [Grouping](index) source by key and counts elements in each group to the given [destination](../each-count-to#kotlin.collections%24eachCountTo(kotlin.collections.Grouping((kotlin.collections.eachCountTo.T,%20kotlin.collections.eachCountTo.K)),%20kotlin.collections.eachCountTo.M)/destination) map. ``` fun <T, K, M : MutableMap<in K, Int>> Grouping<T, K>.eachCountTo(     destination: M ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [fold](../fold) Groups elements from the [Grouping](index) source by key and applies [operation](../fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.Function2((kotlin.collections.fold.K,%20kotlin.collections.fold.T,%20kotlin.collections.fold.R)),%20kotlin.Function3((kotlin.collections.fold.K,%20kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is provided by [initialValueSelector](../fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.Function2((kotlin.collections.fold.K,%20kotlin.collections.fold.T,%20kotlin.collections.fold.R)),%20kotlin.Function3((kotlin.collections.fold.K,%20kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initialValueSelector) function. ``` fun <T, K, R> Grouping<T, K>.fold(     initialValueSelector: (key: K, element: T) -> R,     operation: (key: K, accumulator: R, element: T) -> R ): Map<K, R> ``` Groups elements from the [Grouping](index) source by key and applies [operation](../fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the same [initialValue](../fold#kotlin.collections%24fold(kotlin.collections.Grouping((kotlin.collections.fold.T,%20kotlin.collections.fold.K)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initialValue) for each group. ``` fun <T, K, R> Grouping<T, K>.fold(     initialValue: R,     operation: (accumulator: R, element: T) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [foldTo](../fold-to) Groups elements from the [Grouping](index) source by key and applies [operation](../fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](../fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map. An initial value of accumulator is provided by [initialValueSelector](../fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.Function2((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.R)),%20kotlin.Function3((kotlin.collections.foldTo.K,%20kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/initialValueSelector) function. ``` fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(     destination: M,     initialValueSelector: (key: K, element: T) -> R,     operation: (key: K, accumulator: R, element: T) -> R ): M ``` Groups elements from the [Grouping](index) source by key and applies [operation](../fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/operation) to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](../fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/destination) map. An initial value of accumulator is the same [initialValue](../fold-to#kotlin.collections%24foldTo(kotlin.collections.Grouping((kotlin.collections.foldTo.T,%20kotlin.collections.foldTo.K)),%20kotlin.collections.foldTo.M,%20kotlin.collections.foldTo.R,%20kotlin.Function2((kotlin.collections.foldTo.R,%20kotlin.collections.foldTo.T,%20)))/initialValue) for each group. ``` fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(     destination: M,     initialValue: R,     operation: (accumulator: R, element: T) -> R ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [reduce](../reduce) Groups elements from the [Grouping](index) source by key and applies the reducing [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Grouping((kotlin.collections.reduce.T,%20kotlin.collections.reduce.K)),%20kotlin.Function3((kotlin.collections.reduce.K,%20kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the first element of the group. ``` fun <S, T : S, K> Grouping<T, K>.reduce(     operation: (key: K, accumulator: S, element: T) -> S ): Map<K, S> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [reduceTo](../reduce-to) Groups elements from the [Grouping](index) source by key and applies the reducing [operation](../reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/operation) to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in the given [destination](../reduce-to#kotlin.collections%24reduceTo(kotlin.collections.Grouping((kotlin.collections.reduceTo.T,%20kotlin.collections.reduceTo.K)),%20kotlin.collections.reduceTo.M,%20kotlin.Function3((kotlin.collections.reduceTo.K,%20kotlin.collections.reduceTo.S,%20kotlin.collections.reduceTo.T,%20)))/destination) map. An initial value of accumulator is the first element of the group. ``` fun <S, T : S, K, M : MutableMap<in K, S>> Grouping<T, K>.reduceTo(     destination: M,     operation: (key: K, accumulator: S, element: T) -> S ): M ``` kotlin sourceIterator sourceIterator ============== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Grouping](index) / [sourceIterator](source-iterator) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun sourceIterator(): Iterator<T> ``` Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) over the elements of the source of this grouping. kotlin keyOf keyOf ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Grouping](index) / [keyOf](key-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun keyOf(element: T): K ``` Extracts the key of an [element](key-of#kotlin.collections.Grouping%24keyOf(kotlin.collections.Grouping.T)/element). kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / <contains> **Platform and version requirements:** ``` fun contains(element: @UnsafeVariance E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open operator fun contains(element: E): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / <size> **Platform and version requirements:** ``` val size: Int ``` **Platform and version requirements:** JS (1.1) ``` open val size: Int ``` kotlin HashSet HashSet ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) **Platform and version requirements:** ``` class HashSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` typealias HashSet<E> = HashSet<E> ``` **Platform and version requirements:** JS (1.1) ``` open class HashSet<E> : AbstractMutableSet<E>, MutableSet<E> ``` The implementation of the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface, backed by a [HashMap](../-hash-map/index#kotlin.collections.HashMap) instance. Constructors ------------ **Platform and version requirements:** JS (1.0) #### [<init>](-init-) Constructs a new empty [HashSet](index#kotlin.collections.HashSet). ``` <init>() ``` ``` <init>(initialCapacity: Int, loadFactor: Float) ``` ``` <init>(initialCapacity: Int) ``` Constructs a new [HashSet](index#kotlin.collections.HashSet) filled with the elements of the specified collection. ``` <init>(elements: Collection<E>) ``` Properties ---------- #### <size> **Platform and version requirements:** ``` val size: Int ``` **Platform and version requirements:** JS (1.1) ``` open val size: Int ``` Functions --------- #### <add> Adds the specified element to the set. **Platform and version requirements:** ``` fun add(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun add(element: E): Boolean ``` **Platform and version requirements:** #### [addAll](add-all) ``` fun addAll(elements: Collection<E>): Boolean ``` #### <clear> Removes all elements from this collection. **Platform and version requirements:** ``` fun clear() ``` **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` #### <contains> **Platform and version requirements:** ``` fun contains(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open operator fun contains(element: E): Boolean ``` **Platform and version requirements:** #### [containsAll](contains-all) ``` fun containsAll(elements: Collection<E>): Boolean ``` #### [isEmpty](is-empty) **Platform and version requirements:** ``` fun isEmpty(): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun isEmpty(): Boolean ``` #### <iterator> Returns an iterator over the elements of this object. **Platform and version requirements:** ``` fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** JS (1.1) ``` open fun iterator(): MutableIterator<E> ``` #### <remove> Removes a single instance of the specified element from this collection, if it is present. **Platform and version requirements:** ``` fun remove(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun remove(element: E): Boolean ``` **Platform and version requirements:** #### [removeAll](remove-all) ``` fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [retainAll](retain-all) ``` fun retainAll(elements: Collection<E>): Boolean ``` Inherited Functions ------------------- **Platform and version requirements:** #### [addAll](../-abstract-mutable-set/add-all) ``` open fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [containsAll](../-abstract-mutable-set/contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JS (1.1) #### [equals](../-abstract-mutable-set/equals) Compares this set with another set instance with the unordered structural equality. ``` open fun equals(other: Any?): Boolean ``` **Platform and version requirements:** JS (1.1) #### [hashCode](../-abstract-mutable-set/hash-code) Returns the hash code value for this set. ``` open fun hashCode(): Int ``` **Platform and version requirements:** #### [removeAll](../-abstract-mutable-set/remove-all) ``` open fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [retainAll](../-abstract-mutable-set/retain-all) ``` open fun retainAll(elements: Collection<E>): Boolean ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Set<T>.minus(element: T): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Set((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Set<T>.minusElement(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element) if it isn't already in this set. ``` operator fun <T> Set<T>.plus(element: T): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection, which aren't already in this set. The returned set preserves the element iteration order of the original set. ``` operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Set((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element) if it isn't already in this set. ``` fun <T> Set<T>.plusElement(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- #### [LinkedHashSet](../-linked-hash-set/index) The implementation of the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface, backed by a [LinkedHashMap](../-linked-hash-map/index#kotlin.collections.LinkedHashMap) instance. **Platform and version requirements:** ``` class LinkedHashSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` typealias LinkedHashSet<E> = LinkedHashSet<E> ``` **Platform and version requirements:** JS (1.1) ``` open class LinkedHashSet<E> : HashSet<E>, MutableSet<E> ```
programming_docs
kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / <add> **Platform and version requirements:** ``` fun add(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun add(element: E): Boolean ``` Adds the specified element to the set. **Return** `true` if the element has been added, `false` if the element is already contained in the set. kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / <remove> **Platform and version requirements:** ``` fun remove(element: E): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun remove(element: E): Boolean ``` Removes a single instance of the specified element from this collection, if it is present. **Return** `true` if the element has been successfully removed; `false` if it was not present in the collection. kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / [retainAll](retain-all) **Platform and version requirements:** ``` fun retainAll(elements: Collection<E>): Boolean ``` kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / <iterator> **Platform and version requirements:** ``` fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** JS (1.1) ``` open fun iterator(): MutableIterator<E> ``` Returns an iterator over the elements of this object. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0) ``` <init>() ``` Constructs a new empty [HashSet](index#kotlin.collections.HashSet). **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int) ``` **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int, loadFactor: Float) ``` Constructs a new empty [HashSet](index#kotlin.collections.HashSet). Parameters ---------- `initialCapacity` - the initial capacity (ignored) `loadFactor` - the load factor (ignored) Exceptions ---------- `IllegalArgumentException` - if the initial capacity or load factor are negative **Platform and version requirements:** JS (1.0) ``` <init>(elements: Collection<E>) ``` Constructs a new [HashSet](index#kotlin.collections.HashSet) filled with the elements of the specified collection. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / [removeAll](remove-all) **Platform and version requirements:** ``` fun removeAll(elements: Collection<E>): Boolean ``` kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / <clear> **Platform and version requirements:** ``` fun clear() ``` **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` Removes all elements from this collection. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / [containsAll](contains-all) **Platform and version requirements:** ``` fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` fun isEmpty(): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun isEmpty(): Boolean ``` kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashSet](index) / [addAll](add-all) **Platform and version requirements:** ``` fun addAll(elements: Collection<E>): Boolean ``` kotlin Extensions for java.util.concurrent.ConcurrentMap Extensions for java.util.concurrent.ConcurrentMap ================================================= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [java.util.concurrent.ConcurrentMap](index) **Platform and version requirements:** JVM (1.0) #### [getOrPut](get-or-put) Concurrent getOrPut, that is safe for concurrent maps. ``` fun <K, V> ConcurrentMap<K, V>.getOrPut(     key: K,     defaultValue: () -> V ): V ``` kotlin getOrPut getOrPut ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [java.util.concurrent.ConcurrentMap](index) / [getOrPut](get-or-put) **Platform and version requirements:** JVM (1.0) ``` inline fun <K, V> ConcurrentMap<K, V>.getOrPut(     key: K,     defaultValue: () -> V ): V ``` Concurrent getOrPut, that is safe for concurrent maps. Returns the value for the given [key](get-or-put#kotlin.collections%24getOrPut(java.util.concurrent.ConcurrentMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/key). If the key is not found in the map, calls the [defaultValue](get-or-put#kotlin.collections%24getOrPut(java.util.concurrent.ConcurrentMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/defaultValue) function, puts its result into the map under the given key and returns it. This method guarantees not to put the value into the map if the key is already there, but the [defaultValue](get-or-put#kotlin.collections%24getOrPut(java.util.concurrent.ConcurrentMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/defaultValue) function may be invoked even if the key is already in the map. kotlin ShortIterator ShortIterator ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ShortIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class ShortIterator : Iterator<Short> ``` An iterator over a sequence of values of type `Short`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An iterator over a sequence of values of type `Short`. ``` ShortIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` fun next(): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextShort](next-short) Returns the next value in the sequence without boxing. ``` abstract fun nextShort(): Short ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin nextShort nextShort ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ShortIterator](index) / [nextShort](next-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun nextShort(): Short ``` Returns the next value in the sequence without boxing. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ShortIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ShortIterator() ``` An iterator over a sequence of values of type `Short`. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [ShortIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun next(): Short ``` kotlin MutableListIterator MutableListIterator =================== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableListIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface MutableListIterator<T> :      ListIterator<T>,     MutableIterator<T> ``` An iterator over a mutable collection that supports indexed access. Provides the ability to add, modify and remove elements while iterating. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <add> Adds the specified element [element](add#kotlin.collections.MutableListIterator%24add(kotlin.collections.MutableListIterator.T)/element) into the underlying collection immediately before the element that would be returned by [next](next#kotlin.collections.MutableListIterator%24next()), if any, and after the element that would be returned by [previous](../-list-iterator/previous#kotlin.collections.ListIterator%24previous()), if any. (If the collection contains no elements, the new element becomes the sole element in the collection.) The new element is inserted before the implicit cursor: a subsequent call to [next](next#kotlin.collections.MutableListIterator%24next()) would be unaffected, and a subsequent call to [previous](../-list-iterator/previous#kotlin.collections.ListIterator%24previous()) would return the new element. (This call increases by one the value that would be returned by a call to [nextIndex](../-list-iterator/next-index#kotlin.collections.ListIterator%24nextIndex()) or [previousIndex](../-list-iterator/previous-index#kotlin.collections.ListIterator%24previousIndex()).) ``` abstract fun add(element: T) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hasNext](has-next) Returns `true` if the iteration has more elements. ``` abstract fun hasNext(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> Returns the next element in the iteration. ``` abstract fun next(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <remove> Removes from the underlying collection the last element returned by this iterator. ``` abstract fun remove() ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Replaces the last element returned by [next](next#kotlin.collections.MutableListIterator%24next()) or [previous](../-list-iterator/previous#kotlin.collections.ListIterator%24previous()) with the specified element [element](set#kotlin.collections.MutableListIterator%24set(kotlin.collections.MutableListIterator.T)/element). ``` abstract fun set(element: T) ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableListIterator](index) / <add> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun add(element: T) ``` Adds the specified element [element](add#kotlin.collections.MutableListIterator%24add(kotlin.collections.MutableListIterator.T)/element) into the underlying collection immediately before the element that would be returned by [next](next#kotlin.collections.MutableListIterator%24next()), if any, and after the element that would be returned by [previous](../-list-iterator/previous#kotlin.collections.ListIterator%24previous()), if any. (If the collection contains no elements, the new element becomes the sole element in the collection.) The new element is inserted before the implicit cursor: a subsequent call to [next](next#kotlin.collections.MutableListIterator%24next()) would be unaffected, and a subsequent call to [previous](../-list-iterator/previous#kotlin.collections.ListIterator%24previous()) would return the new element. (This call increases by one the value that would be returned by a call to [nextIndex](../-list-iterator/next-index#kotlin.collections.ListIterator%24nextIndex()) or [previousIndex](../-list-iterator/previous-index#kotlin.collections.ListIterator%24previousIndex()).) kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableListIterator](index) / <remove> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun remove() ``` Removes from the underlying collection the last element returned by this iterator. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableListIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun next(): T ``` Returns the next element in the iteration. kotlin hasNext hasNext ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableListIterator](index) / [hasNext](has-next) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun hasNext(): Boolean ``` Returns `true` if the iteration has more elements. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [MutableListIterator](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun set(element: T) ``` Replaces the last element returned by [next](next#kotlin.collections.MutableListIterator%24next()) or [previous](../-list-iterator/previous#kotlin.collections.ListIterator%24previous()) with the specified element [element](set#kotlin.collections.MutableListIterator%24set(kotlin.collections.MutableListIterator.T)/element). kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / <contains> **Platform and version requirements:** ``` fun contains(element: @UnsafeVariance E): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / <size> **Platform and version requirements:** ``` val size: Int ``` kotlin LinkedHashSet LinkedHashSet ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) **Platform and version requirements:** ``` class LinkedHashSet<E> : MutableSet<E> ``` **Platform and version requirements:** JVM (1.1) ``` typealias LinkedHashSet<E> = LinkedHashSet<E> ``` **Platform and version requirements:** JS (1.1) ``` open class LinkedHashSet<E> : HashSet<E>, MutableSet<E> ``` The implementation of the [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) interface, backed by a [LinkedHashMap](../-linked-hash-map/index#kotlin.collections.LinkedHashMap) instance. This implementation preserves the insertion order of elements during the iteration. Constructors ------------ **Platform and version requirements:** JS (1.0) #### [<init>](-init-) Constructs a new empty [LinkedHashSet](index#kotlin.collections.LinkedHashSet). ``` <init>() ``` ``` <init>(initialCapacity: Int, loadFactor: Float) ``` ``` <init>(initialCapacity: Int) ``` Constructs a new [LinkedHashSet](index#kotlin.collections.LinkedHashSet) filled with the elements of the specified collection. ``` <init>(elements: Collection<E>) ``` Properties ---------- **Platform and version requirements:** #### <size> ``` val size: Int ``` Functions --------- **Platform and version requirements:** #### <add> ``` fun add(element: E): Boolean ``` **Platform and version requirements:** #### [addAll](add-all) ``` fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### <clear> ``` fun clear() ``` **Platform and version requirements:** #### <contains> ``` fun contains(element: E): Boolean ``` **Platform and version requirements:** #### [containsAll](contains-all) ``` fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [isEmpty](is-empty) ``` fun isEmpty(): Boolean ``` **Platform and version requirements:** #### <iterator> ``` fun iterator(): MutableIterator<E> ``` **Platform and version requirements:** #### <remove> ``` fun remove(element: E): Boolean ``` **Platform and version requirements:** #### [removeAll](remove-all) ``` fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [retainAll](retain-all) ``` fun retainAll(elements: Collection<E>): Boolean ``` Inherited Functions ------------------- **Platform and version requirements:** #### [addAll](../-hash-set/add-all) ``` fun addAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [containsAll](../-hash-set/contains-all) ``` fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [removeAll](../-hash-set/remove-all) ``` fun removeAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** #### [retainAll](../-hash-set/retain-all) ``` fun retainAll(elements: Collection<E>): Boolean ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [addAll](../add-all) Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.collections.Iterable((kotlin.collections.addAll.T)))/elements) collection to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Iterable<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.addAll.T)))/elements) sequence to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Sequence<T> ): Boolean ``` Adds all elements of the given [elements](../add-all#kotlin.collections%24addAll(kotlin.collections.MutableCollection((kotlin.collections.addAll.T)),%20kotlin.Array((kotlin.collections.addAll.T)))/elements) array to this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection). ``` fun <T> MutableCollection<in T>.addAll(     elements: Array<out T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Set<T>.minus(element: T): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusAssign](../minus-assign) Removes a single instance of the specified [element](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.minusAssign.T)/element) from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     element: T) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.T)))/elements) collection from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Iterable<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.Array((kotlin.collections.minusAssign.T)))/elements) array from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Array<T>) ``` Removes all elements contained in the given [elements](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableCollection((kotlin.collections.minusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.T)))/elements) sequence from this mutable collection. ``` operator fun <T> MutableCollection<in T>.minusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Set((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Set<T>.minusElement(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element) if it isn't already in this set. ``` operator fun <T> Set<T>.plus(element: T): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection, which aren't already in this set. The returned set preserves the element iteration order of the original set. ``` operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Adds the specified [element](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.plusAssign.T)/element) to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     element: T) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.collections.Iterable((kotlin.collections.plusAssign.T)))/elements) collection to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Iterable<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.Array((kotlin.collections.plusAssign.T)))/elements) array to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Array<T>) ``` Adds all elements of the given [elements](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableCollection((kotlin.collections.plusAssign.T)),%20kotlin.sequences.Sequence((kotlin.collections.plusAssign.T)))/elements) sequence to this mutable collection. ``` operator fun <T> MutableCollection<in T>.plusAssign(     elements: Sequence<T>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Set((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element) if it isn't already in this set. ``` fun <T> Set<T>.plusElement(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes a single instance of the specified element from this collection, if it is present. ``` fun <T> MutableCollection<out T>.remove(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeAll](../remove-all) Removes all of this collection's elements that are also contained in the specified collection. ``` fun <T> MutableCollection<out T>.removeAll(     elements: Collection<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.collections.Iterable((kotlin.collections.removeAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Iterable<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.removeAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Sequence<T> ): Boolean ``` Removes all elements from this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are also contained in the given [elements](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableCollection((kotlin.collections.removeAll.T)),%20kotlin.Array((kotlin.collections.removeAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.removeAll(     elements: Array<out T> ): Boolean ``` Removes all elements from this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../remove-all#kotlin.collections%24removeAll(kotlin.collections.MutableIterable((kotlin.collections.removeAll.T)),%20kotlin.Function1((kotlin.collections.removeAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.removeAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [retainAll](../retain-all) Retains only the elements in this collection that are contained in the specified collection. ``` fun <T> MutableCollection<out T>.retainAll(     elements: Collection<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.collections.Iterable((kotlin.collections.retainAll.T)))/elements) collection. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Iterable<T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.Array((kotlin.collections.retainAll.T)))/elements) array. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Array<out T> ): Boolean ``` Retains only elements of this [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) that are contained in the given [elements](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableCollection((kotlin.collections.retainAll.T)),%20kotlin.sequences.Sequence((kotlin.collections.retainAll.T)))/elements) sequence. ``` fun <T> MutableCollection<in T>.retainAll(     elements: Sequence<T> ): Boolean ``` Retains only elements of this [MutableIterable](../-mutable-iterable/index#kotlin.collections.MutableIterable) that match the given [predicate](../retain-all#kotlin.collections%24retainAll(kotlin.collections.MutableIterable((kotlin.collections.retainAll.T)),%20kotlin.Function1((kotlin.collections.retainAll.T,%20kotlin.Boolean)))/predicate). ``` fun <T> MutableIterable<T>.retainAll(     predicate: (T) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ```
programming_docs
kotlin add add === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / <add> **Platform and version requirements:** ``` fun add(element: E): Boolean ``` kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / <remove> **Platform and version requirements:** ``` fun remove(element: E): Boolean ``` kotlin retainAll retainAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / [retainAll](retain-all) **Platform and version requirements:** ``` fun retainAll(elements: Collection<E>): Boolean ``` kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / <iterator> **Platform and version requirements:** ``` fun iterator(): MutableIterator<E> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0) ``` <init>() ``` Constructs a new empty [LinkedHashSet](index#kotlin.collections.LinkedHashSet). **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int) ``` **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int, loadFactor: Float) ``` Constructs a new empty [LinkedHashSet](index#kotlin.collections.LinkedHashSet). Parameters ---------- `initialCapacity` - the initial capacity (ignored) `loadFactor` - the load factor (ignored) Exceptions ---------- `IllegalArgumentException` - if the initial capacity or load factor are negative **Platform and version requirements:** JS (1.0) ``` <init>(elements: Collection<E>) ``` Constructs a new [LinkedHashSet](index#kotlin.collections.LinkedHashSet) filled with the elements of the specified collection. kotlin removeAll removeAll ========= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / [removeAll](remove-all) **Platform and version requirements:** ``` fun removeAll(elements: Collection<E>): Boolean ``` kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / <clear> **Platform and version requirements:** ``` fun clear() ``` kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / [containsAll](contains-all) **Platform and version requirements:** ``` fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` fun isEmpty(): Boolean ``` kotlin addAll addAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LinkedHashSet](index) / [addAll](add-all) **Platform and version requirements:** ``` fun addAll(elements: Collection<E>): Boolean ``` kotlin Iterable Iterable ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Iterable](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface Iterable<out T> ``` Classes that inherit from this interface can be represented as a sequence of elements that can be iterated over. Parameters ---------- `T` - the type of element being iterated over. The iterator is covariant in its element type. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns an iterator over the elements of this object. ``` abstract operator fun iterator(): Iterator<T> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [average](../average) Returns an average value of elements in the collection. ``` fun Iterable<Byte>.average(): Double ``` ``` fun Iterable<Short>.average(): Double ``` ``` fun Iterable<Int>.average(): Double ``` ``` fun Iterable<Long>.average(): Double ``` ``` fun Iterable<Float>.average(): Double ``` ``` fun Iterable<Double>.average(): Double ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOrNull](../max-or-null) Returns the largest element or `null` if there are no elements. ``` fun Iterable<Double>.maxOrNull(): Double? ``` ``` fun Iterable<Float>.maxOrNull(): Float? ``` ``` fun <T : Comparable<T>> Iterable<T>.maxOrNull(): T? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOrNull](../min-or-null) Returns the smallest element or `null` if there are no elements. ``` fun Iterable<Double>.minOrNull(): Double? ``` ``` fun Iterable<Float>.minOrNull(): Float? ``` ``` fun <T : Comparable<T>> Iterable<T>.minOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun <T : Comparable<T>> Iterable<T>.sortedDescending(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../sum) Returns the sum of all elements in the collection. ``` fun Iterable<Byte>.sum(): Int ``` ``` fun Iterable<Short>.sum(): Int ``` ``` fun Iterable<Int>.sum(): Int ``` ``` fun Iterable<Long>.sum(): Long ``` ``` fun Iterable<Float>.sum(): Float ``` ``` fun Iterable<Double>.sum(): Double ``` ``` fun Iterable<UInt>.sum(): UInt ``` ``` fun Iterable<ULong>.sum(): ULong ``` ``` fun Iterable<UByte>.sum(): UInt ``` ``` fun Iterable<UShort>.sum(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../to-mutable-list) Returns a new [MutableList](../-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this collection. ``` fun <T> Iterable<T>.toMutableList(): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T : Comparable<T>> Iterable<T>.toSortedSet(): SortedSet<T> ``` ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharProgression](../../kotlin.ranges/-char-progression/index) A progression of values of type `Char`. ``` open class CharProgression : Iterable<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Collection](../-collection/index) A generic collection of elements. Methods in this interface support only read-only access to the collection; read/write access is supported through the [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) interface. ``` interface Collection<out E> : Iterable<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntProgression](../../kotlin.ranges/-int-progression/index) A progression of values of type `Int`. ``` open class IntProgression : Iterable<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongProgression](../../kotlin.ranges/-long-progression/index) A progression of values of type `Long`. ``` open class LongProgression : Iterable<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableIterable](../-mutable-iterable/index) Classes that inherit from this interface can be represented as a sequence of elements that can be iterated over and that supports removing elements during iteration. ``` interface MutableIterable<out T> : Iterable<T> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UIntProgression](../../kotlin.ranges/-u-int-progression/index) A progression of values of type `UInt`. ``` open class UIntProgression : Iterable<UInt> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [ULongProgression](../../kotlin.ranges/-u-long-progression/index) A progression of values of type `ULong`. ``` open class ULongProgression : Iterable<ULong> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [Iterable](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract operator fun iterator(): Iterator<T> ``` Returns an iterator over the elements of this object. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun contains(element: @UnsafeVariance E): Boolean ``` Checks if the specified element is contained in this collection. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract val size: Int ``` Returns the size of the collection. kotlin List List ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` interface List<out E> : Collection<E> ``` A generic ordered collection of elements. Methods in this interface support only read-only access to the list; read/write access is supported through the [MutableList](../-mutable-list/index#kotlin.collections.MutableList) interface. Parameters ---------- `E` - the type of elements contained in the list. The list is covariant in its element type. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> Returns the size of the collection. ``` abstract val size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks if the specified element is contained in this collection. ``` abstract fun contains(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) Checks if all elements in the specified collection are contained in this collection. ``` abstract fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the element at the specified index in the list. ``` abstract operator fun get(index: Int): E ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](index-of) Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. ``` abstract fun indexOf(element: E): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Returns `true` if the collection is empty (contains no elements), `false` otherwise. ``` abstract fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns an iterator over the elements of this object. ``` abstract fun iterator(): Iterator<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](last-index-of) Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. ``` abstract fun lastIndexOf(element: E): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [listIterator](list-iterator) Returns a list iterator over the elements in this list (in proper sequence). ``` abstract fun listIterator(): ListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence), starting at the specified [index](list-iterator#kotlin.collections.List%24listIterator(kotlin.Int)/index). ``` abstract fun listIterator(index: Int): ListIterator<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subList](sub-list) Returns a view of the portion of this list between the specified [fromIndex](sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/fromIndex) (inclusive) and [toIndex](sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/toIndex) (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. ``` abstract fun subList(fromIndex: Int, toIndex: Int): List<E> ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../last-index) Returns the index of the last item in the list or -1 if the list is empty. ``` val <T> List<T>.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asReversed](../as-reversed) Returns a reversed read-only view of the original List. All changes made in the original list will be reflected in the reversed one. ``` fun <T> List<T>.asReversed(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearch](../binary-search) Searches this list or its range for the provided [element](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T?)),%20kotlin.collections.binarySearch.T?,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of its elements, otherwise the result is undefined. ``` fun <T : Comparable<T>> List<T?>.binarySearch(     element: T?,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for the provided [element](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified [comparator](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.collections.binarySearch.T,%20kotlin.Comparator((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int)/comparator), otherwise the result is undefined. ``` fun <T> List<T>.binarySearch(     element: T,     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` Searches this list or its range for an element for which the given [comparison](../binary-search#kotlin.collections%24binarySearch(kotlin.collections.List((kotlin.collections.binarySearch.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearch.T,%20kotlin.Int)))/comparison) function returns zero using the binary search algorithm. ``` fun <T> List<T>.binarySearch(     fromIndex: Int = 0,     toIndex: Int = size,     comparison: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [binarySearchBy](../binary-search-by) Searches this list or its range for an element having the key returned by the specified [selector](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/selector) function equal to the provided [key](../binary-search-by#kotlin.collections%24binarySearchBy(kotlin.collections.List((kotlin.collections.binarySearchBy.T)),%20kotlin.collections.binarySearchBy.K?,%20kotlin.Int,%20kotlin.Int,%20kotlin.Function1((kotlin.collections.binarySearchBy.T,%20kotlin.collections.binarySearchBy.K?)))/key) value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined. ``` fun <T, K : Comparable<K>> List<T>.binarySearchBy(     key: K?,     fromIndex: Int = 0,     toIndex: Int = size,     selector: (T) -> K? ): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../component1) Returns 1st *element* from the list. ``` operator fun <T> List<T>.component1(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../component2) Returns 2nd *element* from the list. ``` operator fun <T> List<T>.component2(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../component3) Returns 3rd *element* from the list. ``` operator fun <T> List<T>.component3(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../component4) Returns 4th *element* from the list. ``` operator fun <T> List<T>.component4(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../component5) Returns 5th *element* from the list. ``` operator fun <T> List<T>.component5(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](../drop-last) Returns a list containing all elements except last [n](../drop-last#kotlin.collections%24dropLast(kotlin.collections.List((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.dropLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](../drop-last-while) Returns a list containing all elements except last elements that satisfy the given [predicate](../drop-last-while#kotlin.collections%24dropLastWhile(kotlin.collections.List((kotlin.collections.dropLastWhile.T)),%20kotlin.Function1((kotlin.collections.dropLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.dropLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.List((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.List((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.List((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.List((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.List((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0) Returns a list containing all elements that are instances of specified class. ``` fun <R> Iterable<*>.filterIsInstance(     klass: Class<R> ): List<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C,%20java.lang.Class((kotlin.collections.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.List((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? ``` ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> List<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the list is empty. ``` fun <T> List<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](../fold-right) Accumulates value starting with [initial](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../fold-right#kotlin.collections%24foldRight(kotlin.collections.List((kotlin.collections.foldRight.T)),%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.collections.foldRight.T,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <T, R> List<T>.foldRight(     initial: R,     operation: (T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](../fold-right-indexed) Accumulates value starting with [initial](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.collections.List((kotlin.collections.foldRightIndexed.T)),%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldRightIndexed.T,%20kotlin.collections.foldRightIndexed.R,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <T, R> List<T>.foldRightIndexed(     initial: R,     operation: (index: Int, T, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns an element at the given [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) or the result of calling the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/defaultValue) function if the [index](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.List((kotlin.collections.getOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.getOrElse.T)))/index) is out of bounds of this list. ``` fun <T> List<T>.getOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](../get-or-null) Returns an element at the given [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../get-or-null#kotlin.collections%24getOrNull(kotlin.collections.List((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) is out of bounds of this list. ``` fun <T> List<T>.getOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.List((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.indexOf(element: T): Int ``` Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.List((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int ``` Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.List((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the list does not contain such element. ``` fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int ``` Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> List<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.List((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.last(predicate: (T) -> Boolean): T ``` ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.List((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the list does not contain element. ``` fun <T> List<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the list is empty. ``` fun <T> List<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.List((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns this List if it's not `null` and the empty list otherwise. ``` fun <T> List<T>?.orEmpty(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](../reduce-right) Accumulates value starting with the last element and applying [operation](../reduce-right#kotlin.collections%24reduceRight(kotlin.collections.List((kotlin.collections.reduceRight.T)),%20kotlin.Function2((kotlin.collections.reduceRight.T,%20kotlin.collections.reduceRight.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRight(     operation: (T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](../reduce-right-indexed) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed#kotlin.collections%24reduceRightIndexed(kotlin.collections.List((kotlin.collections.reduceRightIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexed.T,%20kotlin.collections.reduceRightIndexed.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexed(     operation: (index: Int, T, acc: S) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](../reduce-right-indexed-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-indexed-or-null#kotlin.collections%24reduceRightIndexedOrNull(kotlin.collections.List((kotlin.collections.reduceRightIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceRightIndexedOrNull.T,%20kotlin.collections.reduceRightIndexedOrNull.S,%20)))/operation) from right to left to each element with its index in the original list and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightIndexedOrNull(     operation: (index: Int, T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](../reduce-right-or-null) Accumulates value starting with the last element and applying [operation](../reduce-right-or-null#kotlin.collections%24reduceRightOrNull(kotlin.collections.List((kotlin.collections.reduceRightOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceRightOrNull.T,%20kotlin.collections.reduceRightOrNull.S,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <S, T : S> List<T>.reduceRightOrNull(     operation: (T, acc: S) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> List<T?>.requireNoNulls(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.2) ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the list is empty or has more than one element. ``` fun <T> List<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the list is empty or has more than one element. ``` fun <T> List<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [slice](../slice) Returns a list containing elements at indices in the specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> List<T>.slice(indices: IntRange): List<T> ``` Returns a list containing elements at specified [indices](../slice#kotlin.collections%24slice(kotlin.collections.List((kotlin.collections.slice.T)),%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun <T> List<T>.slice(indices: Iterable<Int>): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Iterable<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](../take-last) Returns a list containing last [n](../take-last#kotlin.collections%24takeLast(kotlin.collections.List((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> List<T>.takeLast(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](../take-last-while) Returns a list containing last elements satisfying the given [predicate](../take-last-while#kotlin.collections%24takeLastWhile(kotlin.collections.List((kotlin.collections.takeLastWhile.T)),%20kotlin.Function1((kotlin.collections.takeLastWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> List<T>.takeLastWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCStringArray](../../kotlinx.cinterop/to-c-string-array) Convert this list of Kotlin strings to C array of C strings, allocating memory for the array and C strings with given [AutofreeScope](../../kotlinx.cinterop/-autofree-scope/index). ``` fun List<String>.toCStringArray(     autofreeScope: AutofreeScope ): CPointer<CPointerVar<ByteVar>> ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun <T : CPointed> List<CPointer<T>?>.toCValues(): CValues<CPointerVar<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T> Iterable<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractList](../-abstract-list/index) Provides a skeletal implementation of the read-only [List](index#kotlin.collections.List) interface. ``` abstract class AbstractList<out E> :      AbstractCollection<E>,     List<E> ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [EnumEntries](../../kotlin.enums/-enum-entries) A specialized immutable implementation of [List](index#kotlin.collections.List) interface that contains all enum entries of the specified enum type [E](../../kotlin.enums/-enum-entries#E). [EnumEntries](../../kotlin.enums/-enum-entries) contains all enum entries in the order they are declared in the source code, consistently with the corresponding [Enum.ordinal](../../kotlin/-enum/ordinal#kotlin.Enum%24ordinal) values. ``` sealed interface EnumEntries<E : Enum<E>> : List<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableList](../-mutable-list/index) A generic ordered collection of elements that supports adding and removing elements. ``` interface MutableList<E> : List<E>, MutableCollection<E> ```
programming_docs
kotlin listIterator listIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / [listIterator](list-iterator) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun listIterator(): ListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun listIterator(index: Int): ListIterator<E> ``` Returns a list iterator over the elements in this list (in proper sequence), starting at the specified [index](list-iterator#kotlin.collections.List%24listIterator(kotlin.Int)/index). kotlin lastIndexOf lastIndexOf =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / [lastIndexOf](last-index-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun lastIndexOf(element: @UnsafeVariance E): Int ``` Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. kotlin subList subList ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / [subList](sub-list) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun subList(fromIndex: Int, toIndex: Int): List<E> ``` Returns a view of the portion of this list between the specified [fromIndex](sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/fromIndex) (inclusive) and [toIndex](sub-list#kotlin.collections.List%24subList(kotlin.Int,%20kotlin.Int)/toIndex) (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. Structural changes in the base list make the behavior of the view undefined. kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun iterator(): Iterator<E> ``` Returns an iterator over the elements of this object. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` Checks if all elements in the specified collection are contained in this collection. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun isEmpty(): Boolean ``` Returns `true` if the collection is empty (contains no elements), `false` otherwise. kotlin indexOf indexOf ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / [indexOf](index-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract fun indexOf(element: @UnsafeVariance E): Int ``` Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [List](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` abstract operator fun get(index: Int): E ``` Returns the element at the specified index in the list. kotlin IndexedValue IndexedValue ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [IndexedValue](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` data class IndexedValue<out T> ``` Data class representing a value from a collection or sequence, along with its index in that collection or sequence. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Data class representing a value from a collection or sequence, along with its index in that collection or sequence. ``` IndexedValue(index: Int, value: T) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [index](--index--) the index of the value in the collection or sequence. ``` val index: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <value> the underlying value. ``` val value: T ``` kotlin index index ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [IndexedValue](index) / [index](--index--) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val index: Int ``` the index of the value in the collection or sequence. Property -------- `index` - the index of the value in the collection or sequence. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [IndexedValue](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` IndexedValue(index: Int, value: T) ``` Data class representing a value from a collection or sequence, along with its index in that collection or sequence. kotlin value value ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [IndexedValue](index) / <value> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val value: T ``` the underlying value. Property -------- `value` - the underlying value. kotlin AbstractSet AbstractSet =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractSet](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` abstract class AbstractSet<out E> :      AbstractCollection<E>,     Set<E> ``` Provides a skeletal implementation of the read-only [Set](../-set/index#kotlin.collections.Set) interface. This class is intended to help implementing read-only sets so it doesn't support concurrent modification tracking. Parameters ---------- `E` - the type of elements contained in the set. The set is covariant in its element type. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Provides a skeletal implementation of the read-only [Set](../-set/index#kotlin.collections.Set) interface. ``` AbstractSet() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Compares this set with other set instance with the unordered structural equality. ``` open fun equals(other: Any?): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hashCode](hash-code) Returns the hash code value for this set. ``` open fun hashCode(): Int ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Set<T>.minus(element: T): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Set((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` Returns a set containing all elements of the original set except the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Set((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Set<T>.minusElement(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element) if it isn't already in this set. ``` operator fun <T> Set<T>.plus(element: T): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection, which aren't already in this set. The returned set preserves the element iteration order of the original set. ``` operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> ``` Returns a set containing all elements of the original set and the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Set((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence, which aren't already in this set. ``` operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` Returns a set containing all elements of the original set and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Set((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element) if it isn't already in this set. ``` fun <T> Set<T>.plusElement(element: T): Set<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ```
programming_docs
kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractSet](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun hashCode(): Int ``` Returns the hash code value for this set. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractSet](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected AbstractSet() ``` Provides a skeletal implementation of the read-only [Set](../-set/index#kotlin.collections.Set) interface. This class is intended to help implementing read-only sets so it doesn't support concurrent modification tracking. Parameters ---------- `E` - the type of elements contained in the set. The set is covariant in its element type. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractSet](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun equals(other: Any?): Boolean ``` Compares this set with other set instance with the unordered structural equality. **Return** true, if [other](equals#kotlin.collections.AbstractSet%24equals(kotlin.Any?)/other) instance is a [Set](../-set/index#kotlin.collections.Set) of the same size, all elements of which are contained in this set. kotlin toArray toArray ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) / [toArray](to-array) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected open fun toArray(): Array<Any?> ``` Returns new array of type `Array<Any?>` with the elements of this collection. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected open fun <T> toArray(array: Array<T>): Array<T> ``` Fills the provided [array](to-array#kotlin.collections.AbstractCollection%24toArray(kotlin.Array((kotlin.collections.AbstractCollection.toArray.T)))/array) or creates new array of the same type and fills it with the elements of this collection. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun contains(element: @UnsafeVariance E): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val size: Int ``` kotlin AbstractCollection AbstractCollection ================== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` abstract class AbstractCollection<out E> : Collection<E> ``` Provides a skeletal implementation of the read-only [Collection](../-collection/index#kotlin.collections.Collection) interface. Parameters ---------- `E` - the type of elements contained in the collection. The collection is covariant in its element type. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Provides a skeletal implementation of the read-only [Collection](../-collection/index#kotlin.collections.Collection) interface. ``` AbstractCollection() ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <size> ``` abstract val size: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> ``` open fun contains(element: E): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) ``` open fun containsAll(elements: Collection<E>): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> ``` abstract fun iterator(): Iterator<E> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toArray](to-array) Returns new array of type `Array<Any?>` with the elements of this collection. ``` open fun toArray(): Array<Any?> ``` Fills the provided [array](to-array#kotlin.collections.AbstractCollection%24toArray(kotlin.Array((kotlin.collections.AbstractCollection.toArray.T)))/array) or creates new array of the same type and fills it with the elements of this collection. ``` open fun <T> toArray(array: Array<T>): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns a string representation of the object. ``` open fun toString(): String ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../indices) Returns an [IntRange](../../kotlin.ranges/-int-range/index) of the valid indices for this collection. ``` val Collection<*>.indices: IntRange ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Iterable((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if collection has at least one element. ``` fun <T> Iterable<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Iterable((kotlin.collections.any.T)),%20kotlin.Function1((kotlin.collections.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Returns this collection as an [Iterable](../-iterable/index#kotlin.collections.Iterable). ``` fun <T> Iterable<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original collection returning its elements when being iterated. ``` fun <T> Iterable<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.collections%24associate(kotlin.collections.Iterable((kotlin.collections.associate.T)),%20kotlin.Function1((kotlin.collections.associate.T,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../-map/index#kotlin.collections.Map) containing the elements from the given collection indexed by the key returned from [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Iterable<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.collections%24associateBy(kotlin.collections.Iterable((kotlin.collections.associateBy.T)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.collections.associateBy.T,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given collection. ``` fun <T, K, V> Iterable<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given collection and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.collections%24associateByTo(kotlin.collections.Iterable((kotlin.collections.associateByTo.T)),%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.collections.associateByTo.T,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.collections%24associateTo(kotlin.collections.Iterable((kotlin.collections.associateTo.T)),%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.collections.associateTo.T,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given collection. ``` fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../-map/index#kotlin.collections.Map) where keys are elements from the given collection and values are produced by the [valueSelector](../associate-with#kotlin.collections%24associateWith(kotlin.collections.Iterable((kotlin.collections.associateWith.K)),%20kotlin.Function1((kotlin.collections.associateWith.K,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Iterable<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.collections%24associateWithTo(kotlin.collections.Iterable((kotlin.collections.associateWithTo.K)),%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.collections.associateWithTo.K,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this collection into a list of lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Iterable<T>.chunked(size: Int): List<List<T>> ``` Splits this collection into several lists each not exceeding the given [size](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.collections%24chunked(kotlin.collections.Iterable((kotlin.collections.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.chunked.T)),%20kotlin.collections.chunked.R)))/transform) function to an each. ``` fun <T, R> Iterable<T>.chunked(     size: Int,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.collections%24contains(kotlin.collections.Iterable((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the collection. ``` operator fun <T> Iterable<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](../contains-all) Checks if all elements in the specified collection are contained in this collection. ``` fun <T> Collection<T>.containsAll(     elements: Collection<T> ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Iterable((kotlin.collections.count.T)),%20kotlin.Function1((kotlin.collections.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a list containing only distinct elements from the given collection. ``` fun <T> Iterable<T>.distinct(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a list containing only elements from the given collection having distinct keys returned by the given [selector](../distinct-by#kotlin.collections%24distinctBy(kotlin.collections.Iterable((kotlin.collections.distinctBy.T)),%20kotlin.Function1((kotlin.collections.distinctBy.T,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <T, K> Iterable<T>.distinctBy(     selector: (T) -> K ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a list containing all elements except first [n](../drop#kotlin.collections%24drop(kotlin.collections.Iterable((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.drop(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a list containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.collections%24dropWhile(kotlin.collections.Iterable((kotlin.collections.dropWhile.T)),%20kotlin.Function1((kotlin.collections.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.dropWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.collections%24elementAt(kotlin.collections.Iterable((kotlin.collections.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.collections.Iterable((kotlin.collections.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.elementAtOrElse.T)))/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this collection. ``` fun <T> Iterable<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a list containing only elements matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Iterable((kotlin.collections.filter.T)),%20kotlin.Function1((kotlin.collections.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filter(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a list containing only elements matching the given [predicate](../filter-indexed#kotlin.collections%24filterIndexed(kotlin.collections.Iterable((kotlin.collections.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.collections.Iterable((kotlin.collections.filterIndexedTo.T)),%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstance](../filter-is-instance) Returns a list containing all elements that are instances of specified type parameter R. ``` fun <R> Iterable<*>.filterIsInstance(): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIsInstanceTo](../filter-is-instance-to) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.collections%24filterIsInstanceTo(kotlin.collections.Iterable((kotlin.Any?)),%20kotlin.collections.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a list containing all elements not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Iterable((kotlin.collections.filterNot.T)),%20kotlin.Function1((kotlin.collections.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.filterNot(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a list containing all elements that are not `null`. ``` fun <T : Any> Iterable<T?>.filterNotNull(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.collections%24filterNotNullTo(kotlin.collections.Iterable((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Iterable((kotlin.collections.filterNotTo.T)),%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.collections.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Iterable((kotlin.collections.filterTo.T)),%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.collections.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.collections%24find(kotlin.collections.Iterable((kotlin.collections.find.T)),%20kotlin.Function1((kotlin.collections.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.collections%24findLast(kotlin.collections.Iterable((kotlin.collections.findLast.T)),%20kotlin.Function1((kotlin.collections.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Iterable<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.collections%24first(kotlin.collections.Iterable((kotlin.collections.first.T)),%20kotlin.Function1((kotlin.collections.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Iterable((kotlin.collections.firstNotNullOf.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOf.T,%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to elements of this collection in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Iterable((kotlin.collections.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.collections.firstNotNullOfOrNull.T,%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this collection in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.collections%24firstOrNull(kotlin.collections.Iterable((kotlin.collections.firstOrNull.T)),%20kotlin.Function1((kotlin.collections.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Iterable<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Iterable((kotlin.collections.flatMap.T)),%20kotlin.Function1((kotlin.collections.flatMap.T,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original collection. ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMap(     transform: (T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../flat-map-indexed#kotlin.collections%24flatMapIndexed(kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original collection. ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): List<R> ``` ``` fun <T, R> Iterable<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original collection, to the given [destination](../flat-map-indexed-to#kotlin.collections%24flatMapIndexedTo(kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.T)),%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each element of original collection, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Iterable((kotlin.collections.flatMapTo.T)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a single list of all elements from all collections in the given collection. ``` fun <T> Iterable<Iterable<T>>.flatten(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.collections%24fold(kotlin.collections.Iterable((kotlin.collections.fold.T)),%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.collections.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Iterable<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.collections%24foldIndexed(kotlin.collections.Iterable((kotlin.collections.foldIndexed.T)),%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.collections.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <T, R> Iterable<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterable((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Iterable<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.collections%24forEachIndexed(kotlin.collections.Iterable((kotlin.collections.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Iterable<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Iterable<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by#kotlin.collections%24groupBy(kotlin.collections.Iterable((kotlin.collections.groupBy.T)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.collections.groupBy.T,%20kotlin.collections.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Iterable<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/valueTransform) function applied to each element of the original collection by the key returned by the given [keySelector](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.collections%24groupByTo(kotlin.collections.Iterable((kotlin.collections.groupByTo.T)),%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.collections.groupByTo.T,%20kotlin.collections.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../-grouping/index) source from a collection to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.collections%24groupingBy(kotlin.collections.Iterable((kotlin.collections.groupingBy.T)),%20kotlin.Function1((kotlin.collections.groupingBy.T,%20kotlin.collections.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Iterable<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this array if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.C,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the array is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : Array<*>, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.collections%24indexOf(kotlin.collections.Iterable((kotlin.collections.indexOf.T)),%20kotlin.collections.indexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.collections%24indexOfFirst(kotlin.collections.Iterable((kotlin.collections.indexOfFirst.T)),%20kotlin.Function1((kotlin.collections.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.collections%24indexOfLast(kotlin.collections.Iterable((kotlin.collections.indexOfLast.T)),%20kotlin.Function1((kotlin.collections.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the collection does not contain such element. ``` fun <T> Iterable<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intersect](../intersect) Returns a set containing all elements that are contained by both this collection and the specified collection. ``` infix fun <T> Iterable<T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if the collection is not empty. ``` fun <T> Collection<T>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable collection is either null or empty. ``` fun <T> Collection<T>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.collections%24joinTo(kotlin.collections.Iterable((kotlin.collections.joinTo.T)),%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Iterable<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.collections%24joinToString(kotlin.collections.Iterable((kotlin.collections.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.collections.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Iterable<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Iterable<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.collections%24last(kotlin.collections.Iterable((kotlin.collections.last.T)),%20kotlin.Function1((kotlin.collections.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.collections%24lastIndexOf(kotlin.collections.Iterable((kotlin.collections.lastIndexOf.T)),%20kotlin.collections.lastIndexOf.T)/element), or -1 if the collection does not contain element. ``` fun <T> Iterable<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the collection is empty. ``` fun <T> Iterable<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.collections%24lastOrNull(kotlin.collections.Iterable((kotlin.collections.lastOrNull.T)),%20kotlin.Function1((kotlin.collections.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Iterable((kotlin.collections.map.T)),%20kotlin.Function1((kotlin.collections.map.T,%20kotlin.collections.map.R)))/transform) function to each element in the original collection. ``` fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a list containing the results of applying the given [transform](../map-indexed#kotlin.collections%24mapIndexed(kotlin.collections.Iterable((kotlin.collections.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexed.T,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original collection. ``` fun <T, R> Iterable<T>.mapIndexed(     transform: (index: Int, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.collections%24mapIndexedNotNull(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNull.T,%20kotlin.collections.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original collection. ``` fun <T, R : Any> Iterable<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original collection and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.collections%24mapIndexedNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedNotNullTo.T)),%20kotlin.collections.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedNotNullTo.T,%20kotlin.collections.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/transform) function to each element and its index in the original collection and appends the results to the given [destination](../map-indexed-to#kotlin.collections%24mapIndexedTo(kotlin.collections.Iterable((kotlin.collections.mapIndexedTo.T)),%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.mapIndexedTo.T,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Iterable((kotlin.collections.mapNotNull.T)),%20kotlin.Function1((kotlin.collections.mapNotNull.T,%20kotlin.collections.mapNotNull.R?)))/transform) function to each element in the original collection. ``` fun <T, R : Any> Iterable<T>.mapNotNull(     transform: (T) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each element in the original collection and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Iterable((kotlin.collections.mapNotNullTo.T)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.mapNotNullTo.T,%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/transform) function to each element of the original collection and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Iterable((kotlin.collections.mapTo.T)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.mapTo.T,%20kotlin.collections.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Iterable((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfOrNull.T)),%20kotlin.Function1((kotlin.collections.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Iterable((kotlin.collections.maxOfWith.T)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.maxOfWith.T,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.maxOfWithOrNull.T,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Iterable((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Iterable((kotlin.collections.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Iterable((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Iterable((kotlin.collections.minOfOrNull.T)),%20kotlin.Function1((kotlin.collections.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Iterable<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Iterable((kotlin.collections.minOfWith.T)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.minOfWith.T,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the collection. ``` fun <T, R> Iterable<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Iterable((kotlin.collections.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.minOfWithOrNull.T,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the collection or `null` if there are no elements. ``` fun <T, R> Iterable<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.minus.T)/element). ``` operator fun <T> Iterable<T>.minus(element: T): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.Array((kotlin.collections.minus.T)))/elements) array. ``` operator fun <T> Iterable<T>.minus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.collections.Iterable((kotlin.collections.minus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.minus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection except the elements contained in the given [elements](../minus#kotlin.collections%24minus(kotlin.collections.Iterable((kotlin.collections.minus.T)),%20kotlin.sequences.Sequence((kotlin.collections.minus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.minus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a list containing all elements of the original collection without the first occurrence of the given [element](../minus-element#kotlin.collections%24minusElement(kotlin.collections.Iterable((kotlin.collections.minusElement.T)),%20kotlin.collections.minusElement.T)/element). ``` fun <T> Iterable<T>.minusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Iterable((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Iterable((kotlin.collections.minWithOrNull.T)),%20kotlin.Comparator((kotlin.collections.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Iterable<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the collection has no elements. ``` fun <T> Iterable<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Iterable((kotlin.collections.none.T)),%20kotlin.Function1((kotlin.collections.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.C,%20kotlin.Function1((kotlin.collections.onEach.T,%20kotlin.Unit)))/action) on each element and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.C,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.onEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the collection itself afterwards. ``` fun <T, C : Iterable<T>> C.onEachIndexed(     action: (index: Int, T) -> Unit ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns this Collection if it's not `null` and the empty list otherwise. ``` fun <T> Collection<T>?.orEmpty(): Collection<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original collection into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.collections%24partition(kotlin.collections.Iterable((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Iterable<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a list containing all elements of the original collection and then the given [element](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.plus.T)/element). ``` operator fun <T> Iterable<T>.plus(element: T): List<T> ``` ``` operator fun <T> Collection<T>.plus(element: T): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.Array((kotlin.collections.plus.T)))/elements) array. ``` operator fun <T> Iterable<T>.plus(     elements: Array<out T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Array<out T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.collections.Iterable((kotlin.collections.plus.T)))/elements) collection. ``` operator fun <T> Iterable<T>.plus(     elements: Iterable<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Iterable<T> ): List<T> ``` Returns a list containing all elements of the original collection and then all elements of the given [elements](../plus#kotlin.collections%24plus(kotlin.collections.Iterable((kotlin.collections.plus.T)),%20kotlin.sequences.Sequence((kotlin.collections.plus.T)))/elements) sequence. ``` operator fun <T> Iterable<T>.plus(     elements: Sequence<T> ): List<T> ``` ``` operator fun <T> Collection<T>.plus(     elements: Sequence<T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a list containing all elements of the original collection and then the given [element](../plus-element#kotlin.collections%24plusElement(kotlin.collections.Iterable((kotlin.collections.plusElement.T)),%20kotlin.collections.plusElement.T)/element). ``` fun <T> Iterable<T>.plusElement(element: T): List<T> ``` ``` fun <T> Collection<T>.plusElement(element: T): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this collection. ``` fun <T> Collection<T>.random(): T ``` Returns a random element from this collection using the specified source of randomness. ``` fun <T> Collection<T>.random(random: Random): T ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this collection, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(): T? ``` Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty. ``` fun <T> Collection<T>.randomOrNull(random: Random): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.collections%24reduce(kotlin.collections.Iterable((kotlin.collections.reduce.T)),%20kotlin.Function2((kotlin.collections.reduce.S,%20kotlin.collections.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.collections%24reduceIndexed(kotlin.collections.Iterable((kotlin.collections.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexed.S,%20kotlin.collections.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.collections%24reduceIndexedOrNull(kotlin.collections.Iterable((kotlin.collections.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.reduceIndexedOrNull.S,%20kotlin.collections.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original collection. ``` fun <S, T : S> Iterable<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.collections%24reduceOrNull(kotlin.collections.Iterable((kotlin.collections.reduceOrNull.T)),%20kotlin.Function2((kotlin.collections.reduceOrNull.S,%20kotlin.collections.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Iterable<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../reversed) Returns a list with elements in reversed order. ``` fun <T> Iterable<T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a list containing successive accumulation values generated by applying [operation](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.collections%24runningFold(kotlin.collections.Iterable((kotlin.collections.runningFold.T)),%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.collections.runningFold.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.collections%24runningFoldIndexed(kotlin.collections.Iterable((kotlin.collections.runningFoldIndexed.T)),%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.collections.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.collections%24runningReduce(kotlin.collections.Iterable((kotlin.collections.runningReduce.T)),%20kotlin.Function2((kotlin.collections.runningReduce.S,%20kotlin.collections.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduce(     operation: (acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.collections%24runningReduceIndexed(kotlin.collections.Iterable((kotlin.collections.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningReduceIndexed.S,%20kotlin.collections.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. ``` fun <S, T : S> Iterable<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): List<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a list containing successive accumulation values generated by applying [operation](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.collections%24scan(kotlin.collections.Iterable((kotlin.collections.scan.T)),%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.collections.scan.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original collection and current accumulator value that starts with [initial](../scan-indexed#kotlin.collections%24scanIndexed(kotlin.collections.Iterable((kotlin.collections.scanIndexed.T)),%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.collections.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Iterable<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [shuffled](../shuffled) Returns a new list with the elements of this list randomly shuffled using the specified [random](../shuffled#kotlin.collections%24shuffled(kotlin.collections.Iterable((kotlin.collections.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Iterable<T>.shuffled(random: Random): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.collections%24single(kotlin.collections.Iterable((kotlin.collections.single.T)),%20kotlin.Function1((kotlin.collections.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the collection is empty or has more than one element. ``` fun <T> Iterable<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.collections%24singleOrNull(kotlin.collections.Iterable((kotlin.collections.singleOrNull.T)),%20kotlin.Function1((kotlin.collections.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Iterable<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.collections%24sortedBy(kotlin.collections.Iterable((kotlin.collections.sortedBy.T)),%20kotlin.Function1((kotlin.collections.sortedBy.T,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedBy(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.collections%24sortedByDescending(kotlin.collections.Iterable((kotlin.collections.sortedByDescending.T)),%20kotlin.Function1((kotlin.collections.sortedByDescending.T,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(     selector: (T) -> R? ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a list of all elements sorted according to the specified [comparator](../sorted-with#kotlin.collections%24sortedWith(kotlin.collections.Iterable((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Iterable<T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subtract](../subtract) Returns a set containing all elements that are contained by this collection and not contained by the specified collection. ``` infix fun <T> Iterable<T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.collections%24sumBy(kotlin.collections.Iterable((kotlin.collections.sumBy.T)),%20kotlin.Function1((kotlin.collections.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.collections%24sumByDouble(kotlin.collections.Iterable((kotlin.collections.sumByDouble.T)),%20kotlin.Function1((kotlin.collections.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.collections%24sumOf(kotlin.collections.Iterable((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the collection. ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt ``` ``` fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a list containing first [n](../take#kotlin.collections%24take(kotlin.collections.Iterable((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Iterable<T>.take(n: Int): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a list containing first elements satisfying the given [predicate](../take-while#kotlin.collections%24takeWhile(kotlin.collections.Iterable((kotlin.collections.takeWhile.T)),%20kotlin.Function1((kotlin.collections.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../to-boolean-array) Returns an array of Boolean containing all of the elements of this collection. ``` fun Collection<Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../to-byte-array) Returns an array of Byte containing all of the elements of this collection. ``` fun Collection<Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../to-char-array) Returns an array of Char containing all of the elements of this collection. ``` fun Collection<Char>.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.collections%24toCollection(kotlin.collections.Iterable((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../to-double-array) Returns an array of Double containing all of the elements of this collection. ``` fun Collection<Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../to-float-array) Returns an array of Float containing all of the elements of this collection. ``` fun Collection<Float>.toFloatArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Iterable<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../to-int-array) Returns an array of Int containing all of the elements of this collection. ``` fun Collection<Int>.toIntArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Iterable<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../to-long-array) Returns an array of Long containing all of the elements of this collection. ``` fun Collection<Long>.toLongArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../to-map) Returns a new map containing all key-value pairs from the given collection of pairs. ``` fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given collection of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given collection. ``` fun <T> Iterable<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Iterable<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../to-short-array) Returns an array of Short containing all of the elements of this collection. ``` fun Collection<Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../to-u-byte-array) Returns an array of UByte containing all of the elements of this collection. ``` fun Collection<UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../to-u-int-array) Returns an array of UInt containing all of the elements of this collection. ``` fun Collection<UInt>.toUIntArray(): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../to-u-long-array) Returns an array of ULong containing all of the elements of this collection. ``` fun Collection<ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../to-u-short-array) Returns an array of UShort containing all of the elements of this collection. ``` fun Collection<UShort>.toUShortArray(): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [union](../union) Returns a set containing all distinct elements from both collections. ``` infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this collection, *second* list is built from the second values of each pair from this collection. ``` fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a list of snapshots of the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<List<T>> ``` Returns a list of results of applying the given [transform](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/size) sliding along this collection with the given [step](../windowed#kotlin.collections%24windowed(kotlin.collections.Iterable((kotlin.collections.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.collections.windowed.T)),%20kotlin.collections.windowed.R)))/step). ``` fun <T, R> Iterable<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a lazy [Iterable](../-iterable/index#kotlin.collections.Iterable) that wraps each element of the original collection into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a list of pairs built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Array<out R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Array<out R>,     transform: (a: T, b: R) -> V ): List<V> ``` Returns a list of pairs built from the elements of `this` collection and [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)))/other) collection with the same index. The returned list has length of the shortest collection. ``` infix fun <T, R> Iterable<T>.zip(     other: Iterable<R> ): List<Pair<T, R>> ``` Returns a list of values built from the elements of `this` collection and the [other](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/other) collection with the same index using the provided [transform](../zip#kotlin.collections%24zip(kotlin.collections.Iterable((kotlin.collections.zip.T)),%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.collections.zip.T,%20kotlin.collections.zip.R,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest collection. ``` fun <T, R, V> Iterable<T>.zip(     other: Iterable<R>,     transform: (a: T, b: R) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a list of pairs of each two adjacent elements in this collection. ``` fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> ``` Returns a list containing the results of applying the given [transform](../zip-with-next#kotlin.collections%24zipWithNext(kotlin.collections.Iterable((kotlin.collections.zipWithNext.T)),%20kotlin.Function2((kotlin.collections.zipWithNext.T,%20,%20kotlin.collections.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this collection. ``` fun <T, R> Iterable<T>.zipWithNext(     transform: (a: T, b: T) -> R ): List<R> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractList](../-abstract-list/index) Provides a skeletal implementation of the read-only [List](../-list/index#kotlin.collections.List) interface. ``` abstract class AbstractList<out E> :      AbstractCollection<E>,     List<E> ``` #### [AbstractMutableCollection](../-abstract-mutable-collection/index) Provides a skeletal implementation of the [MutableCollection](../-mutable-collection/index#kotlin.collections.MutableCollection) interface. **Platform and version requirements:** ``` abstract class AbstractMutableCollection<E> :      MutableCollection<E> ``` **Platform and version requirements:** JVM (1.1) ``` abstract class AbstractMutableCollection<E> :      MutableCollection<E>,     AbstractCollection<E> ``` **Platform and version requirements:** JS (1.1) ``` abstract class AbstractMutableCollection<E> :      AbstractCollection<E>,     MutableCollection<E> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractSet](../-abstract-set/index) Provides a skeletal implementation of the read-only [Set](../-set/index#kotlin.collections.Set) interface. ``` abstract class AbstractSet<out E> :      AbstractCollection<E>,     Set<E> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun iterator(): Iterator<E> ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun toString(): String ``` Returns a string representation of the object. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` protected AbstractCollection() ``` Provides a skeletal implementation of the read-only [Collection](../-collection/index#kotlin.collections.Collection) interface. Parameters ---------- `E` - the type of elements contained in the collection. The collection is covariant in its element type. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun containsAll(     elements: Collection<@UnsafeVariance E> ): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [AbstractCollection](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` kotlin LongIterator LongIterator ============ [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LongIterator](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract class LongIterator : Iterator<Long> ``` An iterator over a sequence of values of type `Long`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An iterator over a sequence of values of type `Long`. ``` LongIterator() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <next> ``` fun next(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nextLong](next-long) Returns the next value in the sequence without boxing. ``` abstract fun nextLong(): Long ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../../kotlin.sequences/as-sequence) Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [operation](../for-each#kotlin.collections%24forEach(kotlin.collections.Iterator((kotlin.collections.forEach.T)),%20kotlin.Function1((kotlin.collections.forEach.T,%20kotlin.Unit)))/operation) on each element of this [Iterator](../-iterator/index#kotlin.collections.Iterator). ``` fun <T> Iterator<T>.forEach(operation: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [iterator](../iterator) Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. ``` operator fun <T> Iterator<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns an [Iterator](../-iterator/index#kotlin.collections.Iterator) that wraps each element produced by the original iterator into an [IndexedValue](../-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LongIterator](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` LongIterator() ``` An iterator over a sequence of values of type `Long`. kotlin next next ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LongIterator](index) / <next> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun next(): Long ``` kotlin nextLong nextLong ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [LongIterator](index) / [nextLong](next-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun nextLong(): Long ``` Returns the next value in the sequence without boxing. kotlin toList toList ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [java.util.Enumeration](index) / [toList](to-list) **Platform and version requirements:** JVM (1.0) ``` fun <T> Enumeration<T>.toList(): List<T> ``` Returns a list containing the elements returned by this enumeration in the order they are returned by the enumeration. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = java.util.Hashtable<String, Int>() numbers.put("one", 1) numbers.put("two", 2) numbers.put("three", 3) // when you have an Enumeration from some old code val enumeration: java.util.Enumeration<Int> = numbers.elements() // you can convert it to list and transform further with list operations val list = enumeration.toList().sorted() println(list) // [1, 2, 3] //sampleEnd } ``` kotlin Extensions for java.util.Enumeration Extensions for java.util.Enumeration ==================================== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [java.util.Enumeration](index) **Platform and version requirements:** JVM (1.0) #### <iterator> Creates an [Iterator](../-iterator/index#kotlin.collections.Iterator) for an [java.util.Enumeration](https://docs.oracle.com/javase/8/docs/api/java/util/Enumeration.html), allowing to use it in `for` loops. ``` operator fun <T> Enumeration<T>.iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0) #### [toList](to-list) Returns a list containing the elements returned by this enumeration in the order they are returned by the enumeration. ``` fun <T> Enumeration<T>.toList(): List<T> ``` kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [java.util.Enumeration](index) / <iterator> **Platform and version requirements:** JVM (1.0) ``` operator fun <T> Enumeration<T>.iterator(): Iterator<T> ``` Creates an [Iterator](../-iterator/index#kotlin.collections.Iterator) for an [java.util.Enumeration](https://docs.oracle.com/javase/8/docs/api/java/util/Enumeration.html), allowing to use it in `for` loops. ``` import java.util.* fun main(args: Array<String>) { //sampleStart val vector = Vector<String>().apply { add("RED") add("GREEN") add("BLUE") } // iterator() extension is called here for (e in vector.elements()) { println("The element is $e") } //sampleEnd } ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / <size> **Platform and version requirements:** ``` val size: Int ``` **Platform and version requirements:** JS (1.1) ``` open val size: Int ``` Returns the number of key/value pairs in the map. kotlin values values ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / <values> **Platform and version requirements:** ``` val values: MutableCollection<V> ``` kotlin HashMap HashMap ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) **Platform and version requirements:** ``` class HashMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` typealias HashMap<K, V> = HashMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` open class HashMap<K, V> :      AbstractMutableMap<K, V>,     MutableMap<K, V> ``` Hash table based implementation of the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface. This implementation makes no guarantees regarding the order of enumeration of [keys](../-abstract-mutable-map/keys#kotlin.collections.AbstractMutableMap%24keys), [values](../-abstract-mutable-map/values#kotlin.collections.AbstractMutableMap%24values) and [entries](entries#kotlin.collections.HashMap%24entries) collections. Constructors ------------ **Platform and version requirements:** JS (1.0) #### [<init>](-init-) Constructs an empty [HashMap](index#kotlin.collections.HashMap) instance. ``` <init>() ``` ``` <init>(initialCapacity: Int, loadFactor: Float) ``` ``` <init>(initialCapacity: Int) ``` Constructs an instance of [HashMap](index#kotlin.collections.HashMap) filled with the contents of the specified original map. ``` <init>(original: Map<out K, V>) ``` Properties ---------- #### <entries> Returns a [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) of all key/value pairs in this map. **Platform and version requirements:** ``` val entries: MutableSet<MutableEntry<K, V>> ``` **Platform and version requirements:** JS (1.1) ``` open val entries: MutableSet<MutableEntry<K, V>> ``` **Platform and version requirements:** #### <keys> ``` val keys: MutableSet<K> ``` #### <size> Returns the number of key/value pairs in the map. **Platform and version requirements:** ``` val size: Int ``` **Platform and version requirements:** JS (1.1) ``` open val size: Int ``` **Platform and version requirements:** #### <values> ``` val values: MutableCollection<V> ``` Functions --------- #### <clear> Removes all elements from this map. **Platform and version requirements:** ``` fun clear() ``` **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` #### [containsKey](contains-key) Returns `true` if the map contains the specified [key](../-map/contains-key#kotlin.collections.Map%24containsKey(kotlin.collections.Map.K)/key). **Platform and version requirements:** ``` fun containsKey(key: K): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun containsKey(key: K): Boolean ``` #### [containsValue](contains-value) Returns `true` if the map maps one or more keys to the specified [value](../-map/contains-value#kotlin.collections.Map%24containsValue(kotlin.collections.Map.V)/value). **Platform and version requirements:** ``` fun containsValue(value: V): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun containsValue(value: V): Boolean ``` #### <get> Returns the value corresponding to the given [key](../-map/get#kotlin.collections.Map%24get(kotlin.collections.Map.K)/key), or `null` if such a key is not present in the map. **Platform and version requirements:** ``` operator fun get(key: K): V? ``` **Platform and version requirements:** JS (1.1) ``` open operator fun get(key: K): V? ``` **Platform and version requirements:** #### [isEmpty](is-empty) ``` fun isEmpty(): Boolean ``` #### <put> Associates the specified [value](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/value) with the specified [key](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/key) in the map. **Platform and version requirements:** ``` fun put(key: K, value: V): V? ``` **Platform and version requirements:** JS (1.1) ``` open fun put(key: K, value: V): V? ``` **Platform and version requirements:** #### [putAll](put-all) ``` fun putAll(from: Map<out K, V>) ``` #### <remove> Removes the specified key and its corresponding value from this map. **Platform and version requirements:** ``` fun remove(key: K): V? ``` **Platform and version requirements:** JS (1.1) ``` open fun remove(key: K): V? ``` Inherited Functions ------------------- **Platform and version requirements:** #### [isEmpty](../-abstract-mutable-map/is-empty) ``` open fun isEmpty(): Boolean ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all entries match the given [predicate](../all#kotlin.collections%24all(kotlin.collections.Map((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.all.K,%20kotlin.collections.all.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.all(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if map has at least one entry. ``` fun <K, V> Map<out K, V>.any(): Boolean ``` Returns `true` if at least one entry matches the given [predicate](../any#kotlin.collections%24any(kotlin.collections.Map((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.any.K,%20kotlin.collections.any.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.any(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Creates an [Iterable](../-iterable/index#kotlin.collections.Iterable) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Creates a [Sequence](../../kotlin.sequences/-sequence/index) instance that wraps the original map returning its entries when being iterated. ``` fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Checks if the map contains the given key. ``` operator fun <K, V> Map<out K, V>.contains(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsKey](../contains-key) Returns `true` if the map contains the specified [key](../contains-key#kotlin.collections%24containsKey(kotlin.collections.Map((kotlin.collections.containsKey.K,%20kotlin.Any?)),%20kotlin.collections.containsKey.K)/key). ``` fun <K> Map<out K, *>.containsKey(key: K): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsValue](../contains-value) Returns `true` if the map maps one or more keys to the specified [value](../contains-value#kotlin.collections%24containsValue(kotlin.collections.Map((kotlin.collections.containsValue.K,%20kotlin.collections.containsValue.V)),%20kotlin.collections.containsValue.V)/value). ``` fun <K, V> Map<K, V>.containsValue(value: V): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of entries in this map. ``` fun <K, V> Map<out K, V>.count(): Int ``` Returns the number of entries matching the given [predicate](../count#kotlin.collections%24count(kotlin.collections.Map((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.count.K,%20kotlin.collections.count.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.count(     predicate: (Entry<K, V>) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a new map containing all key-value pairs matching the given [predicate](../filter#kotlin.collections%24filter(kotlin.collections.Map((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filter.K,%20kotlin.collections.filter.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filter(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterKeys](../filter-keys) Returns a map containing all key-value pairs with keys matching the given [predicate](../filter-keys#kotlin.collections%24filterKeys(kotlin.collections.Map((kotlin.collections.filterKeys.K,%20kotlin.collections.filterKeys.V)),%20kotlin.Function1((kotlin.collections.filterKeys.K,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterKeys(     predicate: (K) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a new map containing all key-value pairs not matching the given [predicate](../filter-not#kotlin.collections%24filterNot(kotlin.collections.Map((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNot.K,%20kotlin.collections.filterNot.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterNot(     predicate: (Entry<K, V>) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all entries not matching the given [predicate](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/predicate) into the given [destination](../filter-not-to#kotlin.collections%24filterNotTo(kotlin.collections.Map((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.collections.filterNotTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterNotTo.K,%20kotlin.collections.filterNotTo.V)),%20kotlin.Boolean)))/destination). ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all entries matching the given [predicate](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/predicate) into the mutable map given as [destination](../filter-to#kotlin.collections%24filterTo(kotlin.collections.Map((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.collections.filterTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.filterTo.K,%20kotlin.collections.filterTo.V)),%20kotlin.Boolean)))/destination) parameter. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(     destination: M,     predicate: (Entry<K, V>) -> Boolean ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterValues](../filter-values) Returns a map containing all key-value pairs with values matching the given [predicate](../filter-values#kotlin.collections%24filterValues(kotlin.collections.Map((kotlin.collections.filterValues.K,%20kotlin.collections.filterValues.V)),%20kotlin.Function1((kotlin.collections.filterValues.V,%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.filterValues(     predicate: (V) -> Boolean ): Map<K, V> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.collections%24firstNotNullOf(kotlin.collections.Map((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOf.K,%20kotlin.collections.firstNotNullOf.V)),%20kotlin.collections.firstNotNullOf.R?)))/transform) function being applied to entries of this map in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOf(     transform: (Entry<K, V>) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.collections%24firstNotNullOfOrNull(kotlin.collections.Map((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.firstNotNullOfOrNull.K,%20kotlin.collections.firstNotNullOfOrNull.V)),%20kotlin.collections.firstNotNullOfOrNull.R?)))/transform) function being applied to entries of this map in iteration order, or `null` if no non-null value was produced. ``` fun <K, V, R : Any> Map<out K, V>.firstNotNullOfOrNull(     transform: (Entry<K, V>) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single list of all elements yielded from results of [transform](../flat-map#kotlin.collections%24flatMap(kotlin.collections.Map((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMap.K,%20kotlin.collections.flatMap.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each entry of original map. ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Iterable<R> ): List<R> ``` ``` fun <K, V, R> Map<out K, V>.flatMap(     transform: (Entry<K, V>) -> Sequence<R> ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/transform) function being invoked on each entry of original map, to the given [destination](../flat-map-to#kotlin.collections%24flatMapTo(kotlin.collections.Map((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.flatMapTo.K,%20kotlin.collections.flatMapTo.V)),%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Iterable<R> ): C ``` ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(     destination: C,     transform: (Entry<K, V>) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.collections%24forEach(kotlin.collections.Map((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.forEach.K,%20kotlin.collections.forEach.V)),%20kotlin.Unit)))/action) on each entry. ``` fun <K, V> Map<out K, V>.forEach(     action: (Entry<K, V>) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [get](../get) Returns the value corresponding to the given [key](../get#kotlin.collections%24get(kotlin.collections.Map((kotlin.collections.get.K,%20kotlin.collections.get.V)),%20kotlin.collections.get.K)/key), or `null` if such a key is not present in the map. ``` operator fun <K, V> Map<out K, V>.get(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](../get-or-else) Returns the value for the given [key](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/key) if the value is present and not `null`. Otherwise, returns the result of the [defaultValue](../get-or-else#kotlin.collections%24getOrElse(kotlin.collections.Map((kotlin.collections.getOrElse.K,%20kotlin.collections.getOrElse.V)),%20kotlin.collections.getOrElse.K,%20kotlin.Function0((kotlin.collections.getOrElse.V)))/defaultValue) function. ``` fun <K, V> Map<K, V>.getOrElse(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrPut](../get-or-put) Returns the value for the given [key](../get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/key) if the value is present and not `null`. Otherwise, calls the [defaultValue](../get-or-put#kotlin.collections%24getOrPut(kotlin.collections.MutableMap((kotlin.collections.getOrPut.K,%20kotlin.collections.getOrPut.V)),%20kotlin.collections.getOrPut.K,%20kotlin.Function0((kotlin.collections.getOrPut.V)))/defaultValue) function, puts its result into the map under the given key and returns the call result. ``` fun <K, V> MutableMap<K, V>.getOrPut(     key: K,     defaultValue: () -> V ): V ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [getValue](../get-value) Returns the value for the given [key](../get-value#kotlin.collections%24getValue(kotlin.collections.Map((kotlin.collections.getValue.K,%20kotlin.collections.getValue.V)),%20kotlin.collections.getValue.K)/key) or throws an exception if there is no such key in the map. ``` fun <K, V> Map<K, V>.getValue(key: K): V ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns this map if it's not empty or the result of calling [defaultValue](../if-empty#kotlin.collections%24ifEmpty(kotlin.collections.ifEmpty.M,%20kotlin.Function0((kotlin.collections.ifEmpty.R)))/defaultValue) function if the map is empty. ``` fun <M, R> M.ifEmpty(     defaultValue: () -> R ): R where M : Map<*, *>, M : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../is-not-empty) Returns `true` if this map is not empty. ``` fun <K, V> Map<out K, V>.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [isNullOrEmpty](../is-null-or-empty) Returns `true` if this nullable map is either null or empty. ``` fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a list containing the results of applying the given [transform](../map#kotlin.collections%24map(kotlin.collections.Map((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.map.K,%20kotlin.collections.map.V)),%20kotlin.collections.map.R)))/transform) function to each entry in the original map. ``` fun <K, V, R> Map<out K, V>.map(     transform: (Entry<K, V>) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeys](../map-keys) Returns a new Map with entries having the keys obtained by applying the [transform](../map-keys#kotlin.collections%24mapKeys(kotlin.collections.Map((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeys.K,%20kotlin.collections.mapKeys.V)),%20kotlin.collections.mapKeys.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R> Map<out K, V>.mapKeys(     transform: (Entry<K, V>) -> R ): Map<R, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapKeysTo](../map-keys-to) Populates the given [destination](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/destination) map with entries having the keys obtained by applying the [transform](../map-keys-to#kotlin.collections%24mapKeysTo(kotlin.collections.Map((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapKeysTo.K,%20kotlin.collections.mapKeysTo.V)),%20kotlin.collections.mapKeysTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map) and the values of this map. ``` fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a list containing only the non-null results of applying the given [transform](../map-not-null#kotlin.collections%24mapNotNull(kotlin.collections.Map((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNull.K,%20kotlin.collections.mapNotNull.V)),%20kotlin.collections.mapNotNull.R?)))/transform) function to each entry in the original map. ``` fun <K, V, R : Any> Map<out K, V>.mapNotNull(     transform: (Entry<K, V>) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/transform) function to each entry in the original map and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.collections%24mapNotNullTo(kotlin.collections.Map((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapNotNullTo.K,%20kotlin.collections.mapNotNullTo.V)),%20kotlin.collections.mapNotNullTo.R?)))/destination). ``` fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(     destination: C,     transform: (Entry<K, V>) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/transform) function to each entry of the original map and appends the results to the given [destination](../map-to#kotlin.collections%24mapTo(kotlin.collections.Map((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapTo.K,%20kotlin.collections.mapTo.V)),%20kotlin.collections.mapTo.R)))/destination). ``` fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(     destination: C,     transform: (Entry<K, V>) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValues](../map-values) Returns a new map with entries having the keys of this map and the values obtained by applying the [transform](../map-values#kotlin.collections%24mapValues(kotlin.collections.Map((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValues.K,%20kotlin.collections.mapValues.V)),%20kotlin.collections.mapValues.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R> Map<out K, V>.mapValues(     transform: (Entry<K, V>) -> R ): Map<K, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapValuesTo](../map-values-to) Populates the given [destination](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/destination) map with entries having the keys of this map and the values obtained by applying the [transform](../map-values-to#kotlin.collections%24mapValuesTo(kotlin.collections.Map((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.mapValuesTo.K,%20kotlin.collections.mapValuesTo.V)),%20kotlin.collections.mapValuesTo.R)))/transform) function to each entry in this [Map](../-map/index#kotlin.collections.Map). ``` fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(     destination: M,     transform: (Entry<K, V>) -> R ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first entry yielding the largest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.collections%24maxOf(kotlin.collections.Map((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOf.K,%20kotlin.collections.maxOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.collections%24maxOfOrNull(kotlin.collections.Map((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfOrNull.K,%20kotlin.collections.maxOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.maxOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.collections%24maxOfWith(kotlin.collections.Map((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWith.K,%20kotlin.collections.maxOfWith.V)),%20kotlin.collections.maxOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.maxOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.collections.Map((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.maxOfWithOrNull.K,%20kotlin.collections.maxOfWithOrNull.V)),%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [maxWith](../max-with) Returns the first entry having the largest value according to the provided [comparator](../max-with#kotlin.collections%24maxWith(kotlin.collections.Map((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWith.K,%20kotlin.collections.maxWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.maxWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first entry having the largest value according to the provided [comparator](../max-with-or-null#kotlin.collections%24maxWithOrNull(kotlin.collections.Map((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.maxWithOrNull.K,%20kotlin.collections.maxWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.maxWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first entry yielding the smallest value of the given function or `null` if there are no entries. ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minByOrNull(     selector: (Entry<K, V>) -> R ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.collections%24minOf(kotlin.collections.Map((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOf.K,%20kotlin.collections.minOf.V)),%20kotlin.Double)))/selector) function applied to each entry in the map. ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Double ): Double ``` ``` fun <K, V> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> Float ): Float ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOf(     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.collections%24minOfOrNull(kotlin.collections.Map((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfOrNull.K,%20kotlin.collections.minOfOrNull.V)),%20kotlin.Double)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Double ): Double? ``` ``` fun <K, V> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> Float ): Float? ``` ``` fun <K, V, R : Comparable<R>> Map<out K, V>.minOfOrNull(     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.collections%24minOfWith(kotlin.collections.Map((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWith.K,%20kotlin.collections.minOfWith.V)),%20kotlin.collections.minOfWith.R)))/selector) function applied to each entry in the map. ``` fun <K, V, R> Map<out K, V>.minOfWith(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.collections.Map((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.minOfWithOrNull.K,%20kotlin.collections.minOfWithOrNull.V)),%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each entry in the map or `null` if there are no entries. ``` fun <K, V, R> Map<out K, V>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Entry<K, V>) -> R ): R? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minus](../minus) Returns a map containing all entries of the original map except the entry with the given [key](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.minus.K)/key). ``` operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.collections.Iterable((kotlin.collections.minus.K)))/keys) collection. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Iterable<K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.Array((kotlin.collections.minus.K)))/keys) array. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Array<out K> ): Map<K, V> ``` Returns a map containing all entries of the original map except those entries the keys of which are contained in the given [keys](../minus#kotlin.collections%24minus(kotlin.collections.Map((kotlin.collections.minus.K,%20kotlin.collections.minus.V)),%20kotlin.sequences.Sequence((kotlin.collections.minus.K)))/keys) sequence. ``` operator fun <K, V> Map<out K, V>.minus(     keys: Sequence<K> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minusAssign](../minus-assign) Removes the entry with the given [key](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.minusAssign.K)/key) from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) ``` Removes all entries the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.collections.Iterable((kotlin.collections.minusAssign.K)))/keys) collection from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Iterable<K>) ``` Removes all entries the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.Array((kotlin.collections.minusAssign.K)))/keys) array from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Array<out K>) ``` Removes all entries from the keys of which are contained in the given [keys](../minus-assign#kotlin.collections%24minusAssign(kotlin.collections.MutableMap((kotlin.collections.minusAssign.K,%20kotlin.collections.minusAssign.V)),%20kotlin.sequences.Sequence((kotlin.collections.minusAssign.K)))/keys) sequence from this mutable map. ``` operator fun <K, V> MutableMap<K, V>.minusAssign(     keys: Sequence<K>) ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [minWith](../min-with) Returns the first entry having the smallest value according to the provided [comparator](../min-with#kotlin.collections%24minWith(kotlin.collections.Map((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWith.K,%20kotlin.collections.minWith.V)))))/comparator). ``` fun <K, V> Map<out K, V>.minWith(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first entry having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.collections%24minWithOrNull(kotlin.collections.Map((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)),%20kotlin.Comparator((kotlin.collections.Map.Entry((kotlin.collections.minWithOrNull.K,%20kotlin.collections.minWithOrNull.V)))))/comparator) or `null` if there are no entries. ``` fun <K, V> Map<out K, V>.minWithOrNull(     comparator: Comparator<in Entry<K, V>> ): Entry<K, V>? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the map has no entries. ``` fun <K, V> Map<out K, V>.none(): Boolean ``` Returns `true` if no entries match the given [predicate](../none#kotlin.collections%24none(kotlin.collections.Map((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.none.K,%20kotlin.collections.none.V)),%20kotlin.Boolean)))/predicate). ``` fun <K, V> Map<out K, V>.none(     predicate: (Entry<K, V>) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Performs the given [action](../on-each#kotlin.collections%24onEach(kotlin.collections.onEach.M,%20kotlin.Function1((kotlin.collections.Map.Entry((kotlin.collections.onEach.K,%20kotlin.collections.onEach.V)),%20kotlin.Unit)))/action) on each entry and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEach(     action: (Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Performs the given [action](../on-each-indexed#kotlin.collections%24onEachIndexed(kotlin.collections.onEachIndexed.M,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.Map.Entry((kotlin.collections.onEachIndexed.K,%20kotlin.collections.onEachIndexed.V)),%20kotlin.Unit)))/action) on each entry, providing sequential index with the entry, and returns the map itself afterwards. ``` fun <K, V, M : Map<out K, V>> M.onEachIndexed(     action: (index: Int, Entry<K, V>) -> Unit ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](../or-empty) Returns the [Map](../-map/index#kotlin.collections.Map) if its not `null`, or the empty [Map](../-map/index#kotlin.collections.Map) otherwise. ``` fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/pair). ``` operator fun <K, V> Map<out K, V>.plus(     pair: Pair<K, V> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Iterable<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Array<out Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))))/pairs). ``` operator fun <K, V> Map<out K, V>.plus(     pairs: Sequence<Pair<K, V>> ): Map<K, V> ``` Creates a new read-only map by replacing or adding entries to this map from another [map](../plus#kotlin.collections%24plus(kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)),%20kotlin.collections.Map((kotlin.collections.plus.K,%20kotlin.collections.plus.V)))/map). ``` operator fun <K, V> Map<out K, V>.plus(     map: Map<out K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusAssign](../plus-assign) Appends or replaces the given [pair](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/pair) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pair: Pair<K, V>) ``` Appends or replaces all pairs from the given collection of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Iterable((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Iterable<Pair<K, V>>) ``` Appends or replaces all pairs from the given array of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Array<out Pair<K, V>>) ``` Appends or replaces all pairs from the given sequence of [pairs](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))))/pairs) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     pairs: Sequence<Pair<K, V>>) ``` Appends or replaces all entries from the given [map](../plus-assign#kotlin.collections%24plusAssign(kotlin.collections.MutableMap((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)),%20kotlin.collections.Map((kotlin.collections.plusAssign.K,%20kotlin.collections.plusAssign.V)))/map) in this mutable map. ``` operator fun <K, V> MutableMap<in K, in V>.plusAssign(     map: Map<K, V>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [putAll](../put-all) Puts all the given [pairs](../put-all#kotlin.collections%24putAll(kotlin.collections.MutableMap((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)),%20kotlin.Array((kotlin.Pair((kotlin.collections.putAll.K,%20kotlin.collections.putAll.V)))))/pairs) into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Array<out Pair<K, V>>) ``` Puts all the elements of the given collection into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Iterable<Pair<K, V>>) ``` Puts all the elements of the given sequence into this [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) with the first component in the pair being the key and the second the value. ``` fun <K, V> MutableMap<in K, in V>.putAll(     pairs: Sequence<Pair<K, V>>) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [remove](../remove) Removes the specified key and its corresponding value from this map. ``` fun <K, V> MutableMap<out K, V>.remove(key: K): V? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [set](../set) Allows to use the index operator for storing values in a mutable map. ``` operator fun <K, V> MutableMap<K, V>.set(key: K, value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [setValue](../set-value) Stores the value of the property for the given object in this mutable map. ``` operator fun <V> MutableMap<in String, in V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../-list/index#kotlin.collections.List) containing all key-value pairs. ``` fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMap](../to-map) Returns a new read-only map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMap(): Map<K, V> ``` Populates and returns the [destination](../to-map#kotlin.collections%24toMap(kotlin.collections.Map((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given map. ``` fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toMutableMap](../to-mutable-map) Returns a new mutable map containing all key-value pairs from the original map. ``` fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withDefault](../with-default) Returns a wrapper of this read-only map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.Map((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> Map<K, V>.withDefault(     defaultValue: (key: K) -> V ): Map<K, V> ``` Returns a wrapper of this mutable map, having the implicit default value provided with the specified function [defaultValue](../with-default#kotlin.collections%24withDefault(kotlin.collections.MutableMap((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)),%20kotlin.Function1((kotlin.collections.withDefault.K,%20kotlin.collections.withDefault.V)))/defaultValue). ``` fun <K, V> MutableMap<K, V>.withDefault(     defaultValue: (key: K) -> V ): MutableMap<K, V> ``` Inheritors ---------- #### [LinkedHashMap](../-linked-hash-map/index) Hash table based implementation of the [MutableMap](../-mutable-map/index#kotlin.collections.MutableMap) interface, which additionally preserves the insertion order of entries during the iteration. **Platform and version requirements:** ``` class LinkedHashMap<K, V> : MutableMap<K, V> ``` **Platform and version requirements:** JVM (1.1) ``` typealias LinkedHashMap<K, V> = LinkedHashMap<K, V> ``` **Platform and version requirements:** JS (1.1) ``` open class LinkedHashMap<K, V> :      HashMap<K, V>,     MutableMap<K, V> ```
programming_docs
kotlin remove remove ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / <remove> **Platform and version requirements:** ``` fun remove(key: K): V? ``` **Platform and version requirements:** JS (1.1) ``` open fun remove(key: K): V? ``` Removes the specified key and its corresponding value from this map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. kotlin keys keys ==== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / <keys> **Platform and version requirements:** ``` val keys: MutableSet<K> ``` kotlin containsKey containsKey =========== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / [containsKey](contains-key) **Platform and version requirements:** ``` fun containsKey(key: K): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun containsKey(key: K): Boolean ``` Returns `true` if the map contains the specified [key](../-map/contains-key#kotlin.collections.Map%24containsKey(kotlin.collections.Map.K)/key). kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0) ``` <init>() ``` Constructs an empty [HashMap](index#kotlin.collections.HashMap) instance. **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int) ``` **Platform and version requirements:** JS (1.0) ``` <init>(initialCapacity: Int, loadFactor: Float) ``` Constructs an empty [HashMap](index#kotlin.collections.HashMap) instance. Parameters ---------- `initialCapacity` - the initial capacity (ignored) `loadFactor` - the load factor (ignored) Exceptions ---------- `IllegalArgumentException` - if the initial capacity or load factor are negative **Platform and version requirements:** JS (1.0) ``` <init>(original: Map<out K, V>) ``` Constructs an instance of [HashMap](index#kotlin.collections.HashMap) filled with the contents of the specified original map. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / <clear> **Platform and version requirements:** ``` fun clear() ``` **Platform and version requirements:** JS (1.1) ``` open fun clear() ``` Removes all elements from this map. kotlin entries entries ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / <entries> **Platform and version requirements:** ``` val entries: MutableSet<MutableEntry<K, V>> ``` **Platform and version requirements:** JS (1.1) ``` open val entries: MutableSet<MutableEntry<K, V>> ``` Returns a [MutableSet](../-mutable-set/index#kotlin.collections.MutableSet) of all key/value pairs in this map. kotlin put put === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / <put> **Platform and version requirements:** ``` fun put(key: K, value: V): V? ``` **Platform and version requirements:** JS (1.1) ``` open fun put(key: K, value: V): V? ``` Associates the specified [value](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/value) with the specified [key](../-mutable-map/put#kotlin.collections.MutableMap%24put(kotlin.collections.MutableMap.K,%20kotlin.collections.MutableMap.V)/key) in the map. **Return** the previous value associated with the key, or `null` if the key was not present in the map. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / [isEmpty](is-empty) **Platform and version requirements:** ``` fun isEmpty(): Boolean ``` kotlin containsValue containsValue ============= [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / [containsValue](contains-value) **Platform and version requirements:** ``` fun containsValue(value: @UnsafeVariance V): Boolean ``` **Platform and version requirements:** JS (1.1) ``` open fun containsValue(value: V): Boolean ``` Returns `true` if the map maps one or more keys to the specified [value](../-map/contains-value#kotlin.collections.Map%24containsValue(kotlin.collections.Map.V)/value). kotlin putAll putAll ====== [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / [putAll](put-all) **Platform and version requirements:** ``` fun putAll(from: Map<out K, V>) ``` kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.collections](../index) / [HashMap](index) / <get> **Platform and version requirements:** ``` operator fun get(key: K): V? ``` **Platform and version requirements:** JS (1.1) ``` open operator fun get(key: K): V? ``` Returns the value corresponding to the given [key](../-map/get#kotlin.collections.Map%24get(kotlin.collections.Map.K)/key), or `null` if such a key is not present in the map. kotlin staticProperties staticProperties ================ [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [staticProperties](static-properties) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.staticProperties: Collection<KProperty0<*>> ``` Returns static properties declared in this class. Only properties representing static fields of Java classes are considered static. kotlin callSuspendBy callSuspendBy ============= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [callSuspendBy](call-suspend-by) **Platform and version requirements:** JVM (1.3) ``` suspend fun <R> KCallable<R>.callSuspendBy(     args: Map<KParameter, Any?> ): R ``` Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../kotlin.reflect/-k-callable/call-by). Otherwise, calls the suspend function with current continuation. kotlin declaredMemberFunctions declaredMemberFunctions ======================= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [declaredMemberFunctions](declared-member-functions) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.declaredMemberFunctions: Collection<KFunction<*>> ``` Returns non-extension non-static functions declared in this class. kotlin companionObject companionObject =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [companionObject](companion-object) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.companionObject: KClass<*>? ``` Returns a [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance representing the companion object of a given class, or `null` if the class doesn't have a companion object. kotlin Package kotlin.reflect.full Package kotlin.reflect.full =========================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) Extensions for [Kotlin reflection](../../../../../docs/reflection) provided by `kotlin-reflect` library. Exceptions ---------- **Platform and version requirements:** JVM (1.1) #### [IllegalCallableAccessException](-illegal-callable-access-exception/index) An exception that is thrown when `call` is invoked on a callable or `get` or `set` is invoked on a property and that callable is not accessible (in JVM terms) from the calling method. ``` class IllegalCallableAccessException : Exception ``` **Platform and version requirements:** JVM (1.1) #### [IllegalPropertyDelegateAccessException](-illegal-property-delegate-access-exception/index) An exception that is thrown when `getDelegate` is invoked on a [KProperty](../kotlin.reflect/-k-property/index#kotlin.reflect.KProperty) object that was not made accessible with [isAccessible](../kotlin.reflect.jvm/is-accessible). ``` class IllegalPropertyDelegateAccessException : Exception ``` **Platform and version requirements:** JVM (1.1) #### [NoSuchPropertyException](-no-such-property-exception/index) An exception that is thrown when the code tries to introspect a property of a class or a package and that class or the package no longer has that property. ``` class NoSuchPropertyException : Exception ``` Properties ---------- **Platform and version requirements:** JVM (1.1) #### [allSuperclasses](all-superclasses) All superclasses of this class, including indirect ones, in no particular order. Includes superclasses and superinterfaces of the class, but does not include the class itself. The returned collection does not contain more than one instance of any given class. ``` val KClass<*>.allSuperclasses: Collection<KClass<*>> ``` **Platform and version requirements:** JVM (1.1) #### [allSupertypes](all-supertypes) All supertypes of this class, including indirect ones, in no particular order. There is not more than one type in the returned collection that has any given classifier. ``` val KClass<*>.allSupertypes: Collection<KType> ``` **Platform and version requirements:** JVM (1.1) #### [companionObject](companion-object) Returns a [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) instance representing the companion object of a given class, or `null` if the class doesn't have a companion object. ``` val KClass<*>.companionObject: KClass<*>? ``` **Platform and version requirements:** JVM (1.1) #### [companionObjectInstance](companion-object-instance) Returns an instance of the companion object of a given class, or `null` if the class doesn't have a companion object. ``` val KClass<*>.companionObjectInstance: Any? ``` **Platform and version requirements:** JVM (1.1) #### [declaredFunctions](declared-functions) Returns all functions declared in this class. If this is a Java class, it includes all non-static methods (both extensions and non-extensions) declared in the class and the superclasses, as well as static methods declared in the class. ``` val KClass<*>.declaredFunctions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [declaredMemberExtensionFunctions](declared-member-extension-functions) Returns extension functions declared in this class. ``` val KClass<*>.declaredMemberExtensionFunctions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [declaredMemberExtensionProperties](declared-member-extension-properties) Returns extension properties declared in this class. ``` val <T : Any> KClass<T>.declaredMemberExtensionProperties: Collection<KProperty2<T, *, *>> ``` **Platform and version requirements:** JVM (1.1) #### [declaredMemberFunctions](declared-member-functions) Returns non-extension non-static functions declared in this class. ``` val KClass<*>.declaredMemberFunctions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [declaredMemberProperties](declared-member-properties) Returns non-extension properties declared in this class. ``` val <T : Any> KClass<T>.declaredMemberProperties: Collection<KProperty1<T, *>> ``` **Platform and version requirements:** JVM (1.1) #### [declaredMembers](declared-members) Returns all functions and properties declared in this class. Does not include members declared in supertypes. ``` val KClass<*>.declaredMembers: Collection<KCallable<*>> ``` **Platform and version requirements:** JVM (1.1) #### [defaultType](default-type) Returns a type corresponding to the given class with type parameters of that class substituted as the corresponding arguments. For example, for class `MyMap<K, V>` [defaultType](default-type) would return the type `MyMap<K, V>`. ``` val KClass<*>.defaultType: KType ``` **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](extension-receiver-parameter) Returns a parameter representing the extension receiver instance needed to call this callable, or `null` if this callable is not an extension. ``` val KCallable<*>.extensionReceiverParameter: KParameter? ``` **Platform and version requirements:** JVM (1.1) #### <functions> Returns all functions declared in this class, including all non-static methods declared in the class and the superclasses, as well as static methods declared in the class. ``` val KClass<*>.functions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [instanceParameter](instance-parameter) Returns a parameter representing the `this` instance needed to call this callable, or `null` if this callable is not a member of a class and thus doesn't take such parameter. ``` val KCallable<*>.instanceParameter: KParameter? ``` **Platform and version requirements:** JVM (1.1) #### [memberExtensionFunctions](member-extension-functions) Returns extension functions declared in this class and all of its superclasses. ``` val KClass<*>.memberExtensionFunctions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [memberExtensionProperties](member-extension-properties) Returns extension properties declared in this class and all of its superclasses. ``` val <T : Any> KClass<T>.memberExtensionProperties: Collection<KProperty2<T, *, *>> ``` **Platform and version requirements:** JVM (1.1) #### [memberFunctions](member-functions) Returns non-extension non-static functions declared in this class and all of its superclasses. ``` val KClass<*>.memberFunctions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [memberProperties](member-properties) Returns non-extension properties declared in this class and all of its superclasses. ``` val <T : Any> KClass<T>.memberProperties: Collection<KProperty1<T, *>> ``` **Platform and version requirements:** JVM (1.1) #### [primaryConstructor](primary-constructor) Returns the primary constructor of this class, or `null` if this class has no primary constructor. See the [Kotlin language documentation](http://kotlinlang.org/docs/classes.html#constructors) for more information. ``` val <T : Any> KClass<T>.primaryConstructor: KFunction<T>? ``` **Platform and version requirements:** JVM (1.1) #### [starProjectedType](star-projected-type) Creates an instance of [KType](../kotlin.reflect/-k-type/index#kotlin.reflect.KType) with the given classifier, substituting all its type parameters with star projections. The resulting type is not marked as nullable and does not have any annotations. ``` val KClassifier.starProjectedType: KType ``` **Platform and version requirements:** JVM (1.1) #### [staticFunctions](static-functions) Returns static functions declared in this class. ``` val KClass<*>.staticFunctions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [staticProperties](static-properties) Returns static properties declared in this class. Only properties representing static fields of Java classes are considered static. ``` val KClass<*>.staticProperties: Collection<KProperty0<*>> ``` **Platform and version requirements:** JVM (1.1) #### <superclasses> Immediate superclasses of this class, in the order they are listed in the source code. Includes superclasses and superinterfaces of the class, but does not include the class itself. ``` val KClass<*>.superclasses: List<KClass<*>> ``` **Platform and version requirements:** JVM (1.1) #### [valueParameters](value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Functions --------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../kotlin.reflect/-k-callable/call). Otherwise, calls the suspend function with current continuation. ``` suspend fun <R> KCallable<R>.callSuspend(     vararg args: Any? ): R ``` **Platform and version requirements:** JVM (1.3) #### [callSuspendBy](call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../kotlin.reflect/-k-callable/call-by). Otherwise, calls the suspend function with current continuation. ``` suspend fun <R> KCallable<R>.callSuspendBy(     args: Map<KParameter, Any?> ): R ``` **Platform and version requirements:** JVM (1.1) #### <cast> Casts the given [value](cast#kotlin.reflect.full%24cast(kotlin.reflect.KClass((kotlin.reflect.full.cast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) object. Throws an exception if the value is `null` or if it is not an instance of this class. ``` fun <T : Any> KClass<T>.cast(value: Any?): T ``` **Platform and version requirements:** JVM (1.1) #### [createInstance](create-instance) Creates a new instance of the class, calling a constructor which either has no parameters or all parameters of which are optional (see [KParameter.isOptional](../kotlin.reflect/-k-parameter/is-optional)). If there are no or many such constructors, an exception is thrown. ``` fun <T : Any> KClass<T>.createInstance(): T ``` **Platform and version requirements:** JVM (1.1) #### [createType](create-type) Creates a [KType](../kotlin.reflect/-k-type/index#kotlin.reflect.KType) instance with the given classifier, type arguments, nullability and annotations. If the number of passed type arguments is not equal to the total number of type parameters of a classifier, an exception is thrown. If any of the arguments does not satisfy the bounds of the corresponding type parameter, an exception is thrown. ``` fun KClassifier.createType(     arguments: List<KTypeProjection> = emptyList(),     nullable: Boolean = false,     annotations: List<Annotation> = emptyList() ): KType ``` **Platform and version requirements:** JVM (1.1) #### [findAnnotation](find-annotation) Returns an annotation of the given type on this element. ``` fun <T : Annotation> KAnnotatedElement.findAnnotation(): T? ``` **Platform and version requirements:** JVM (1.7) #### [findAnnotations](find-annotations) Returns all annotations of the given type on this element, including individually applied annotations as well as repeated annotations. ``` fun <T : Annotation> KAnnotatedElement.findAnnotations(): List<T> ``` ``` fun <T : Annotation> KAnnotatedElement.findAnnotations(     klass: KClass<T> ): List<T> ``` **Platform and version requirements:** JVM (1.1) #### [findParameterByName](find-parameter-by-name) Returns the parameter of this callable with the given name, or `null` if there's no such parameter. ``` fun KCallable<*>.findParameterByName(     name: String ): KParameter? ``` **Platform and version requirements:** JVM (1.1) #### [getExtensionDelegate](get-extension-delegate) Returns the instance of a delegated **extension property**, or `null` if this property is not delegated. Throws an exception if this is not an extension property. ``` fun KProperty1<*, *>.getExtensionDelegate(): Any? ``` Returns the instance of a delegated **member extension property**, or `null` if this property is not delegated. Throws an exception if this is not an extension property. ``` fun <D> KProperty2<D, *, *>.getExtensionDelegate(     receiver: D ): Any? ``` **Platform and version requirements:** JVM (1.4) #### [hasAnnotation](has-annotation) Returns true if this element is annotated with an annotation of type [T](has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSubclassOf](is-subclass-of) Returns `true` if `this` class is the same or is a (possibly indirect) subclass of [base](is-subclass-of#kotlin.reflect.full%24isSubclassOf(kotlin.reflect.KClass((kotlin.Any)),%20kotlin.reflect.KClass((kotlin.Any)))/base), `false` otherwise. ``` fun KClass<*>.isSubclassOf(base: KClass<*>): Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSubtypeOf](is-subtype-of) Returns `true` if `this` type is the same or is a subtype of [other](is-subtype-of#kotlin.reflect.full%24isSubtypeOf(kotlin.reflect.KType,%20kotlin.reflect.KType)/other), `false` otherwise. ``` fun KType.isSubtypeOf(other: KType): Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSuperclassOf](is-superclass-of) Returns `true` if `this` class is the same or is a (possibly indirect) superclass of [derived](is-superclass-of#kotlin.reflect.full%24isSuperclassOf(kotlin.reflect.KClass((kotlin.Any)),%20kotlin.reflect.KClass((kotlin.Any)))/derived), `false` otherwise. ``` fun KClass<*>.isSuperclassOf(derived: KClass<*>): Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSupertypeOf](is-supertype-of) Returns `true` if `this` type is the same or is a supertype of [other](is-supertype-of#kotlin.reflect.full%24isSupertypeOf(kotlin.reflect.KType,%20kotlin.reflect.KType)/other), `false` otherwise. ``` fun KType.isSupertypeOf(other: KType): Boolean ``` **Platform and version requirements:** JVM (1.1) #### [safeCast](safe-cast) Casts the given [value](safe-cast#kotlin.reflect.full%24safeCast(kotlin.reflect.KClass((kotlin.reflect.full.safeCast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) object. Returns `null` if the value is `null` or if it is not an instance of this class. ``` fun <T : Any> KClass<T>.safeCast(value: Any?): T? ``` **Platform and version requirements:** JVM (1.1) #### [withNullability](with-nullability) Returns a new type with the same classifier, arguments and annotations as the given type, and with the given nullability. ``` fun KType.withNullability(nullable: Boolean): KType ```
programming_docs
kotlin functions functions ========= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / <functions> **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.functions: Collection<KFunction<*>> ``` Returns all functions declared in this class, including all non-static methods declared in the class and the superclasses, as well as static methods declared in the class. kotlin createInstance createInstance ============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [createInstance](create-instance) **Platform and version requirements:** JVM (1.1) ``` fun <T : Any> KClass<T>.createInstance(): T ``` Creates a new instance of the class, calling a constructor which either has no parameters or all parameters of which are optional (see [KParameter.isOptional](../kotlin.reflect/-k-parameter/is-optional)). If there are no or many such constructors, an exception is thrown. kotlin isSupertypeOf isSupertypeOf ============= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [isSupertypeOf](is-supertype-of) **Platform and version requirements:** JVM (1.1) ``` fun KType.isSupertypeOf(other: KType): Boolean ``` Returns `true` if `this` type is the same or is a supertype of [other](is-supertype-of#kotlin.reflect.full%24isSupertypeOf(kotlin.reflect.KType,%20kotlin.reflect.KType)/other), `false` otherwise. kotlin primaryConstructor primaryConstructor ================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [primaryConstructor](primary-constructor) **Platform and version requirements:** JVM (1.1) ``` val <T : Any> KClass<T>.primaryConstructor: KFunction<T>? ``` Returns the primary constructor of this class, or `null` if this class has no primary constructor. See the [Kotlin language documentation](http://kotlinlang.org/docs/classes.html#constructors) for more information. kotlin superclasses superclasses ============ [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / <superclasses> **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.superclasses: List<KClass<*>> ``` Immediate superclasses of this class, in the order they are listed in the source code. Includes superclasses and superinterfaces of the class, but does not include the class itself. kotlin findParameterByName findParameterByName =================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [findParameterByName](find-parameter-by-name) **Platform and version requirements:** JVM (1.1) ``` fun KCallable<*>.findParameterByName(     name: String ): KParameter? ``` Returns the parameter of this callable with the given name, or `null` if there's no such parameter. kotlin declaredMembers declaredMembers =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [declaredMembers](declared-members) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.declaredMembers: Collection<KCallable<*>> ``` Returns all functions and properties declared in this class. Does not include members declared in supertypes. kotlin isSuperclassOf isSuperclassOf ============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [isSuperclassOf](is-superclass-of) **Platform and version requirements:** JVM (1.1) ``` fun KClass<*>.isSuperclassOf(derived: KClass<*>): Boolean ``` Returns `true` if `this` class is the same or is a (possibly indirect) superclass of [derived](is-superclass-of#kotlin.reflect.full%24isSuperclassOf(kotlin.reflect.KClass((kotlin.Any)),%20kotlin.reflect.KClass((kotlin.Any)))/derived), `false` otherwise. kotlin hasAnnotation hasAnnotation ============= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [hasAnnotation](has-annotation) **Platform and version requirements:** JVM (1.4) ``` fun <reified T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` Returns true if this element is annotated with an annotation of type [T](has-annotation#T). kotlin allSuperclasses allSuperclasses =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [allSuperclasses](all-superclasses) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.allSuperclasses: Collection<KClass<*>> ``` All superclasses of this class, including indirect ones, in no particular order. Includes superclasses and superinterfaces of the class, but does not include the class itself. The returned collection does not contain more than one instance of any given class. kotlin valueParameters valueParameters =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [valueParameters](value-parameters) **Platform and version requirements:** JVM (1.1) ``` val KCallable<*>.valueParameters: List<KParameter> ``` Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. kotlin isSubclassOf isSubclassOf ============ [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [isSubclassOf](is-subclass-of) **Platform and version requirements:** JVM (1.1) ``` fun KClass<*>.isSubclassOf(base: KClass<*>): Boolean ``` Returns `true` if `this` class is the same or is a (possibly indirect) subclass of [base](is-subclass-of#kotlin.reflect.full%24isSubclassOf(kotlin.reflect.KClass((kotlin.Any)),%20kotlin.reflect.KClass((kotlin.Any)))/base), `false` otherwise. kotlin getExtensionDelegate getExtensionDelegate ==================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [getExtensionDelegate](get-extension-delegate) **Platform and version requirements:** JVM (1.1) ``` fun KProperty1<*, *>.getExtensionDelegate(): Any? ``` Returns the instance of a delegated **extension property**, or `null` if this property is not delegated. Throws an exception if this is not an extension property. **See Also** [KProperty1.getDelegate](../kotlin.reflect/-k-property1/get-delegate) **Platform and version requirements:** JVM (1.1) ``` fun <D> KProperty2<D, *, *>.getExtensionDelegate(     receiver: D ): Any? ``` Returns the instance of a delegated **member extension property**, or `null` if this property is not delegated. Throws an exception if this is not an extension property. Parameters ---------- `receiver` - the instance of the class used to retrieve the value of the property delegate. **See Also** [KProperty2.getDelegate](../kotlin.reflect/-k-property2/get-delegate) kotlin memberProperties memberProperties ================ [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [memberProperties](member-properties) **Platform and version requirements:** JVM (1.1) ``` val <T : Any> KClass<T>.memberProperties: Collection<KProperty1<T, *>> ``` Returns non-extension properties declared in this class and all of its superclasses. kotlin companionObjectInstance companionObjectInstance ======================= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [companionObjectInstance](companion-object-instance) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.companionObjectInstance: Any? ``` Returns an instance of the companion object of a given class, or `null` if the class doesn't have a companion object. kotlin declaredFunctions declaredFunctions ================= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [declaredFunctions](declared-functions) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.declaredFunctions: Collection<KFunction<*>> ``` Returns all functions declared in this class. If this is a Java class, it includes all non-static methods (both extensions and non-extensions) declared in the class and the superclasses, as well as static methods declared in the class. kotlin findAnnotation findAnnotation ============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [findAnnotation](find-annotation) **Platform and version requirements:** JVM (1.1) ``` fun <reified T : Annotation> KAnnotatedElement.findAnnotation(): T? ``` Returns an annotation of the given type on this element. kotlin instanceParameter instanceParameter ================= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [instanceParameter](instance-parameter) **Platform and version requirements:** JVM (1.1) ``` val KCallable<*>.instanceParameter: KParameter? ``` Returns a parameter representing the `this` instance needed to call this callable, or `null` if this callable is not a member of a class and thus doesn't take such parameter. kotlin defaultType defaultType =========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [defaultType](default-type) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.defaultType: KType ``` **Deprecated:** This function creates a type which rarely makes sense for generic classes. For example, such type can only be used in signatures of members of that class. Use starProjectedType or createType() for clearer semantics. Returns a type corresponding to the given class with type parameters of that class substituted as the corresponding arguments. For example, for class `MyMap<K, V>` [defaultType](default-type) would return the type `MyMap<K, V>`. kotlin memberFunctions memberFunctions =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [memberFunctions](member-functions) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.memberFunctions: Collection<KFunction<*>> ``` Returns non-extension non-static functions declared in this class and all of its superclasses. kotlin cast cast ==== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / <cast> **Platform and version requirements:** JVM (1.1) ``` fun <T : Any> KClass<T>.cast(value: Any?): T ``` Casts the given [value](cast#kotlin.reflect.full%24cast(kotlin.reflect.KClass((kotlin.reflect.full.cast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) object. Throws an exception if the value is `null` or if it is not an instance of this class. **See Also** [KClass.isInstance](../kotlin.reflect/-k-class/is-instance#kotlin.reflect.KClass%24isInstance(kotlin.Any?)) [KClass.safeCast](safe-cast) kotlin extensionReceiverParameter extensionReceiverParameter ========================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [extensionReceiverParameter](extension-receiver-parameter) **Platform and version requirements:** JVM (1.1) ``` val KCallable<*>.extensionReceiverParameter: KParameter? ``` Returns a parameter representing the extension receiver instance needed to call this callable, or `null` if this callable is not an extension. kotlin memberExtensionProperties memberExtensionProperties ========================= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [memberExtensionProperties](member-extension-properties) **Platform and version requirements:** JVM (1.1) ``` val <T : Any> KClass<T>.memberExtensionProperties: Collection<KProperty2<T, *, *>> ``` Returns extension properties declared in this class and all of its superclasses. kotlin withNullability withNullability =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [withNullability](with-nullability) **Platform and version requirements:** JVM (1.1) ``` fun KType.withNullability(nullable: Boolean): KType ``` Returns a new type with the same classifier, arguments and annotations as the given type, and with the given nullability. kotlin staticFunctions staticFunctions =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [staticFunctions](static-functions) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.staticFunctions: Collection<KFunction<*>> ``` Returns static functions declared in this class. kotlin declaredMemberExtensionProperties declaredMemberExtensionProperties ================================= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [declaredMemberExtensionProperties](declared-member-extension-properties) **Platform and version requirements:** JVM (1.1) ``` val <T : Any> KClass<T>.declaredMemberExtensionProperties: Collection<KProperty2<T, *, *>> ``` Returns extension properties declared in this class. kotlin starProjectedType starProjectedType ================= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [starProjectedType](star-projected-type) **Platform and version requirements:** JVM (1.1) ``` val KClassifier.starProjectedType: KType ``` Creates an instance of [KType](../kotlin.reflect/-k-type/index#kotlin.reflect.KType) with the given classifier, substituting all its type parameters with star projections. The resulting type is not marked as nullable and does not have any annotations. **See Also** [KClassifier.createType](create-type) kotlin createType createType ========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [createType](create-type) **Platform and version requirements:** JVM (1.1) ``` fun KClassifier.createType(     arguments: List<KTypeProjection> = emptyList(),     nullable: Boolean = false,     annotations: List<Annotation> = emptyList() ): KType ``` Creates a [KType](../kotlin.reflect/-k-type/index#kotlin.reflect.KType) instance with the given classifier, type arguments, nullability and annotations. If the number of passed type arguments is not equal to the total number of type parameters of a classifier, an exception is thrown. If any of the arguments does not satisfy the bounds of the corresponding type parameter, an exception is thrown. For classifiers representing type parameters, the type argument list must always be empty. For classes, the type argument list should contain arguments for the type parameters of the class. If the class is `inner`, the list should follow with arguments for the type parameters of its outer class, and so forth until a class is not `inner`, or is declared on the top level. kotlin findAnnotations findAnnotations =============== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [findAnnotations](find-annotations) **Platform and version requirements:** JVM (1.7) ``` fun <reified T : Annotation> KAnnotatedElement.findAnnotations(): List<T> ``` ``` fun <T : Annotation> KAnnotatedElement.findAnnotations(     klass: KClass<T> ): List<T> ``` Returns all annotations of the given type on this element, including individually applied annotations as well as repeated annotations. In case the annotation is repeated, instances are extracted from the container annotation class similarly to how it happens in Java reflection ([java.lang.reflect.AnnotatedElement.getAnnotationsByType](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedElement.html#getAnnotationsByType-java.lang.Class-)). This is supported both for Kotlin-repeatable ([kotlin.annotation.Repeatable](../kotlin.annotation/-repeatable/index#kotlin.annotation.Repeatable)) and Java-repeatable ([java.lang.annotation.Repeatable](https://docs.oracle.com/javase/8/docs/api/java/lang/annotation/Repeatable.html)) annotation classes. kotlin safeCast safeCast ======== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [safeCast](safe-cast) **Platform and version requirements:** JVM (1.1) ``` fun <T : Any> KClass<T>.safeCast(value: Any?): T? ``` Casts the given [value](safe-cast#kotlin.reflect.full%24safeCast(kotlin.reflect.KClass((kotlin.reflect.full.safeCast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](../kotlin.reflect/-k-class/index#kotlin.reflect.KClass) object. Returns `null` if the value is `null` or if it is not an instance of this class. **See Also** [KClass.isInstance](../kotlin.reflect/-k-class/is-instance#kotlin.reflect.KClass%24isInstance(kotlin.Any?)) [KClass.cast](cast) kotlin allSupertypes allSupertypes ============= [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [allSupertypes](all-supertypes) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.allSupertypes: Collection<KType> ``` All supertypes of this class, including indirect ones, in no particular order. There is not more than one type in the returned collection that has any given classifier. kotlin declaredMemberExtensionFunctions declaredMemberExtensionFunctions ================================ [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [declaredMemberExtensionFunctions](declared-member-extension-functions) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.declaredMemberExtensionFunctions: Collection<KFunction<*>> ``` Returns extension functions declared in this class. kotlin callSuspend callSuspend =========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [callSuspend](call-suspend) **Platform and version requirements:** JVM (1.3) ``` suspend fun <R> KCallable<R>.callSuspend(     vararg args: Any? ): R ``` Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../kotlin.reflect/-k-callable/call). Otherwise, calls the suspend function with current continuation. kotlin memberExtensionFunctions memberExtensionFunctions ======================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [memberExtensionFunctions](member-extension-functions) **Platform and version requirements:** JVM (1.1) ``` val KClass<*>.memberExtensionFunctions: Collection<KFunction<*>> ``` Returns extension functions declared in this class and all of its superclasses. kotlin isSubtypeOf isSubtypeOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [isSubtypeOf](is-subtype-of) **Platform and version requirements:** JVM (1.1) ``` fun KType.isSubtypeOf(other: KType): Boolean ``` Returns `true` if `this` type is the same or is a subtype of [other](is-subtype-of#kotlin.reflect.full%24isSubtypeOf(kotlin.reflect.KType,%20kotlin.reflect.KType)/other), `false` otherwise. kotlin declaredMemberProperties declaredMemberProperties ======================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect.full](index) / [declaredMemberProperties](declared-member-properties) **Platform and version requirements:** JVM (1.1) ``` val <T : Any> KClass<T>.declaredMemberProperties: Collection<KProperty1<T, *>> ``` Returns non-extension properties declared in this class. kotlin IllegalCallableAccessException IllegalCallableAccessException ============================== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.full](../index) / [IllegalCallableAccessException](index) **Platform and version requirements:** JVM (1.1) ``` class IllegalCallableAccessException : Exception ``` An exception that is thrown when `call` is invoked on a callable or `get` or `set` is invoked on a property and that callable is not accessible (in JVM terms) from the calling method. Parameters ---------- `cause` - the original exception thrown by the JVM. **See Also** [kotlin.reflect.jvm.isAccessible](../../kotlin.reflect.jvm/is-accessible) Constructors ------------ **Platform and version requirements:** JVM (1.0) #### [<init>](-init-) An exception that is thrown when `call` is invoked on a callable or `get` or `set` is invoked on a property and that callable is not accessible (in JVM terms) from the calling method. ``` IllegalCallableAccessException(cause: IllegalAccessException) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [stackTrace](../../kotlin/stack-trace) Returns an array of stack trace elements representing the stack trace pertaining to this throwable. ``` val Throwable.stackTrace: Array<StackTraceElement> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0) #### [printStackTrace](../../kotlin/print-stack-trace) Prints the [detailed description](../../kotlin/stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [writer](../../kotlin/print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintWriter)/writer). ``` fun Throwable.printStackTrace(writer: PrintWriter) ``` Prints the [detailed description](../../kotlin/stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [stream](../../kotlin/print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintStream)/stream). ``` fun Throwable.printStackTrace(stream: PrintStream) ```
programming_docs
kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.full](../index) / [IllegalCallableAccessException](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0) ``` IllegalCallableAccessException(cause: IllegalAccessException) ``` An exception that is thrown when `call` is invoked on a callable or `get` or `set` is invoked on a property and that callable is not accessible (in JVM terms) from the calling method. Parameters ---------- `cause` - the original exception thrown by the JVM. **See Also** [kotlin.reflect.jvm.isAccessible](../../kotlin.reflect.jvm/is-accessible) kotlin IllegalPropertyDelegateAccessException IllegalPropertyDelegateAccessException ====================================== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.full](../index) / [IllegalPropertyDelegateAccessException](index) **Platform and version requirements:** JVM (1.1) ``` class IllegalPropertyDelegateAccessException : Exception ``` An exception that is thrown when `getDelegate` is invoked on a [KProperty](../../kotlin.reflect/-k-property/index#kotlin.reflect.KProperty) object that was not made accessible with [isAccessible](../../kotlin.reflect.jvm/is-accessible). **See Also** [kotlin.reflect.KProperty0.getDelegate](../../kotlin.reflect/-k-property0/get-delegate) [kotlin.reflect.KProperty1.getDelegate](../../kotlin.reflect/-k-property1/get-delegate) [kotlin.reflect.KProperty2.getDelegate](../../kotlin.reflect/-k-property2/get-delegate) [kotlin.reflect.jvm.isAccessible](../../kotlin.reflect.jvm/is-accessible) Constructors ------------ **Platform and version requirements:** JVM (1.0) #### [<init>](-init-) An exception that is thrown when `getDelegate` is invoked on a [KProperty](../../kotlin.reflect/-k-property/index#kotlin.reflect.KProperty) object that was not made accessible with [isAccessible](../../kotlin.reflect.jvm/is-accessible). ``` IllegalPropertyDelegateAccessException(     cause: IllegalAccessException) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [stackTrace](../../kotlin/stack-trace) Returns an array of stack trace elements representing the stack trace pertaining to this throwable. ``` val Throwable.stackTrace: Array<StackTraceElement> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0) #### [printStackTrace](../../kotlin/print-stack-trace) Prints the [detailed description](../../kotlin/stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [writer](../../kotlin/print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintWriter)/writer). ``` fun Throwable.printStackTrace(writer: PrintWriter) ``` Prints the [detailed description](../../kotlin/stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [stream](../../kotlin/print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintStream)/stream). ``` fun Throwable.printStackTrace(stream: PrintStream) ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.full](../index) / [IllegalPropertyDelegateAccessException](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0) ``` IllegalPropertyDelegateAccessException(     cause: IllegalAccessException) ``` An exception that is thrown when `getDelegate` is invoked on a [KProperty](../../kotlin.reflect/-k-property/index#kotlin.reflect.KProperty) object that was not made accessible with [isAccessible](../../kotlin.reflect.jvm/is-accessible). **See Also** [kotlin.reflect.KProperty0.getDelegate](../../kotlin.reflect/-k-property0/get-delegate) [kotlin.reflect.KProperty1.getDelegate](../../kotlin.reflect/-k-property1/get-delegate) [kotlin.reflect.KProperty2.getDelegate](../../kotlin.reflect/-k-property2/get-delegate) [kotlin.reflect.jvm.isAccessible](../../kotlin.reflect.jvm/is-accessible) kotlin NoSuchPropertyException NoSuchPropertyException ======================= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.full](../index) / [NoSuchPropertyException](index) **Platform and version requirements:** JVM (1.1) ``` class NoSuchPropertyException : Exception ``` An exception that is thrown when the code tries to introspect a property of a class or a package and that class or the package no longer has that property. Constructors ------------ **Platform and version requirements:** JVM (1.0) #### [<init>](-init-) An exception that is thrown when the code tries to introspect a property of a class or a package and that class or the package no longer has that property. ``` NoSuchPropertyException(cause: Exception? = null) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [stackTrace](../../kotlin/stack-trace) Returns an array of stack trace elements representing the stack trace pertaining to this throwable. ``` val Throwable.stackTrace: Array<StackTraceElement> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0) #### [printStackTrace](../../kotlin/print-stack-trace) Prints the [detailed description](../../kotlin/stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [writer](../../kotlin/print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintWriter)/writer). ``` fun Throwable.printStackTrace(writer: PrintWriter) ``` Prints the [detailed description](../../kotlin/stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the specified [stream](../../kotlin/print-stack-trace#kotlin%24printStackTrace(kotlin.Throwable,%20java.io.PrintStream)/stream). ``` fun Throwable.printStackTrace(stream: PrintStream) ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect.full](../index) / [NoSuchPropertyException](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0) ``` NoSuchPropertyException(cause: Exception? = null) ``` An exception that is thrown when the code tries to introspect a property of a class or a package and that class or the package no longer has that property. kotlin resume resume ====== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / <resume> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Continuation<T>.resume(value: T) ``` Resumes the execution of the corresponding coroutine passing [value](resume#kotlin.coroutines%24resume(kotlin.coroutines.Continuation((kotlin.coroutines.resume.T)),%20kotlin.coroutines.resume.T)/value) as the return value of the last suspension point. kotlin suspendCoroutine suspendCoroutine ================ [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [suspendCoroutine](suspend-coroutine) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` suspend inline fun <T> suspendCoroutine(     crossinline block: (Continuation<T>) -> Unit ): T ``` Obtains the current continuation instance inside suspend functions and suspends the currently running coroutine. In this function both [Continuation.resume](resume) and [Continuation.resumeWithException](resume-with-exception) can be used either synchronously in the same stack-frame where the suspension function is run or asynchronously later in the same thread or from a different thread of execution. Subsequent invocation of any resume function will produce an [IllegalStateException](../kotlin/-illegal-state-exception/index#kotlin.IllegalStateException). kotlin SuspendFunction SuspendFunction =============== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [SuspendFunction](-suspend-function) **Platform and version requirements:** Native (1.3) ``` interface SuspendFunction<out R> ``` Represents a value of a functional type, such as a lambda, an anonymous function or a function reference. Parameters ---------- `R` - return type of the function. kotlin Package kotlin.coroutines Package kotlin.coroutines ========================= [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) Basic primitives for creating and suspending coroutines: [Continuation](-continuation/index), [CoroutineContext](-coroutine-context/index) interfaces, coroutine creation and suspension top-level functions. Types ----- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [AbstractCoroutineContextElement](-abstract-coroutine-context-element/index) Base class for [CoroutineContext.Element](-coroutine-context/-element/index) implementations. ``` abstract class AbstractCoroutineContextElement : Element ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index) Base class for [CoroutineContext.Key](-coroutine-context/-key) associated with polymorphic [CoroutineContext.Element](-coroutine-context/-element/index) implementation. Polymorphic element implementation implies delegating its [get](-coroutine-context/-element/get) and [minusKey](-coroutine-context/-element/minus-key) to [getPolymorphicElement](get-polymorphic-element) and [minusPolymorphicKey](minus-polymorphic-key) respectively. ``` abstract class AbstractCoroutineContextKey<B : Element, E : B> :      Key<E> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Continuation](-continuation/index) Interface representing a continuation after a suspension point that returns a value of type `T`. ``` interface Continuation<in T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ContinuationInterceptor](-continuation-interceptor/index) Marks coroutine context element that intercepts coroutine continuations. The coroutines framework uses [ContinuationInterceptor.Key](-continuation-interceptor/-key) to retrieve the interceptor and intercepts all coroutine continuations with [interceptContinuation](-continuation-interceptor/intercept-continuation) invocations. ``` interface ContinuationInterceptor : Element ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [CoroutineContext](-coroutine-context/index) Persistent context for the coroutine. It is an indexed set of [Element](-coroutine-context/-element/index) instances. An indexed set is a mix between a set and a map. Every element in this set has a unique [Key](-coroutine-context/-key). ``` interface CoroutineContext ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [EmptyCoroutineContext](-empty-coroutine-context/index) An empty coroutine context. ``` object EmptyCoroutineContext : CoroutineContext, Serializable ``` **Platform and version requirements:** Native (1.3) #### [SuspendFunction](-suspend-function) Represents a value of a functional type, such as a lambda, an anonymous function or a function reference. ``` interface SuspendFunction<out R> ``` Annotations ----------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [RestrictsSuspension](-restricts-suspension/index) Classes and interfaces marked with this annotation are restricted when used as receivers for extension `suspend` functions. These `suspend` extensions can only invoke other member or extension `suspend` functions on this particular receiver and are restricted from calling arbitrary suspension functions. ``` annotation class RestrictsSuspension ``` Properties ---------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [coroutineContext](coroutine-context) Returns the context of the current coroutine. ``` suspend val coroutineContext: CoroutineContext ``` Functions --------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Continuation](-continuation) Creates a [Continuation](-continuation/index) instance with the given [context](-continuation#kotlin.coroutines%24Continuation(kotlin.coroutines.CoroutineContext,%20kotlin.Function1((kotlin.Result((kotlin.coroutines.Continuation.T)),%20kotlin.Unit)))/context) and implementation of [resumeWith](-continuation#kotlin.coroutines%24Continuation(kotlin.coroutines.CoroutineContext,%20kotlin.Function1((kotlin.Result((kotlin.coroutines.Continuation.T)),%20kotlin.Unit)))/resumeWith) method. ``` fun <T> Continuation(     context: CoroutineContext,     resumeWith: (Result<T>) -> Unit ): Continuation<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [createCoroutine](create-coroutine) Creates a coroutine without a receiver and with result type [T](create-coroutine#T). This function creates a new, fresh instance of suspendable computation every time it is invoked. ``` fun <T> (suspend () -> T).createCoroutine(     completion: Continuation<T> ): Continuation<Unit> ``` Creates a coroutine with receiver type [R](create-coroutine#R) and result type [T](create-coroutine#T). This function creates a new, fresh instance of suspendable computation every time it is invoked. ``` fun <R, T> (suspend R.() -> T).createCoroutine(     receiver: R,     completion: Continuation<T> ): Continuation<Unit> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getPolymorphicElement](get-polymorphic-element) Returns the current element if it is associated with the given [key](get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) in a polymorphic manner or `null` otherwise. This method returns non-null value if either [Element.key](-coroutine-context/-element/key) is equal to the given [key](get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) or if the [key](get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) is associated with [Element.key](-coroutine-context/-element/key) via [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index). See [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index) for the example of usage. ``` fun <E : Element> Element.getPolymorphicElement(     key: Key<E> ): E? ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [minusPolymorphicKey](minus-polymorphic-key) Returns empty coroutine context if the element is associated with the given [key](minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) in a polymorphic manner or `null` otherwise. This method returns empty context if either [Element.key](-coroutine-context/-element/key) is equal to the given [key](minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) or if the [key](minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) is associated with [Element.key](-coroutine-context/-element/key) via [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index). See [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index) for the example of usage. ``` fun Element.minusPolymorphicKey(     key: Key<*> ): CoroutineContext ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <resume> Resumes the execution of the corresponding coroutine passing [value](resume#kotlin.coroutines%24resume(kotlin.coroutines.Continuation((kotlin.coroutines.resume.T)),%20kotlin.coroutines.resume.T)/value) as the return value of the last suspension point. ``` fun <T> Continuation<T>.resume(value: T) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [resumeWithException](resume-with-exception) Resumes the execution of the corresponding coroutine so that the [exception](resume-with-exception#kotlin.coroutines%24resumeWithException(kotlin.coroutines.Continuation((kotlin.coroutines.resumeWithException.T)),%20kotlin.Throwable)/exception) is re-thrown right after the last suspension point. ``` fun <T> Continuation<T>.resumeWithException(     exception: Throwable) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [startCoroutine](start-coroutine) Starts a coroutine without a receiver and with result type [T](start-coroutine#T). This function creates and starts a new, fresh instance of suspendable computation every time it is invoked. The [completion](start-coroutine#kotlin.coroutines%24startCoroutine(kotlin.coroutines.SuspendFunction0((kotlin.coroutines.startCoroutine.T)),%20kotlin.coroutines.Continuation((kotlin.coroutines.startCoroutine.T)))/completion) continuation is invoked when the coroutine completes with a result or an exception. ``` fun <T> (suspend () -> T).startCoroutine(     completion: Continuation<T>) ``` Starts a coroutine with receiver type [R](start-coroutine#R) and result type [T](start-coroutine#T). This function creates and starts a new, fresh instance of suspendable computation every time it is invoked. The [completion](start-coroutine#kotlin.coroutines%24startCoroutine(kotlin.coroutines.SuspendFunction1((kotlin.coroutines.startCoroutine.R,%20kotlin.coroutines.startCoroutine.T)),%20kotlin.coroutines.startCoroutine.R,%20kotlin.coroutines.Continuation((kotlin.coroutines.startCoroutine.T)))/completion) continuation is invoked when the coroutine completes with a result or an exception. ``` fun <R, T> (suspend R.() -> T).startCoroutine(     receiver: R,     completion: Continuation<T>) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [suspendCoroutine](suspend-coroutine) Obtains the current continuation instance inside suspend functions and suspends the currently running coroutine. ``` suspend fun <T> suspendCoroutine(     block: (Continuation<T>) -> Unit ): T ``` kotlin coroutineContext coroutineContext ================ [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [coroutineContext](coroutine-context) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` suspend inline val coroutineContext: CoroutineContext ``` Returns the context of the current coroutine. kotlin resumeWithException resumeWithException =================== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [resumeWithException](resume-with-exception) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Continuation<T>.resumeWithException(     exception: Throwable) ``` Resumes the execution of the corresponding coroutine so that the [exception](resume-with-exception#kotlin.coroutines%24resumeWithException(kotlin.coroutines.Continuation((kotlin.coroutines.resumeWithException.T)),%20kotlin.Throwable)/exception) is re-thrown right after the last suspension point. kotlin createCoroutine createCoroutine =============== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [createCoroutine](create-coroutine) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> (suspend () -> T).createCoroutine(     completion: Continuation<T> ): Continuation<Unit> ``` Creates a coroutine without a receiver and with result type [T](create-coroutine#T). This function creates a new, fresh instance of suspendable computation every time it is invoked. To start executing the created coroutine, invoke `resume(Unit)` on the returned [Continuation](-continuation/index) instance. The [completion](create-coroutine#kotlin.coroutines%24createCoroutine(kotlin.coroutines.SuspendFunction0((kotlin.coroutines.createCoroutine.T)),%20kotlin.coroutines.Continuation((kotlin.coroutines.createCoroutine.T)))/completion) continuation is invoked when the coroutine completes with a result or an exception. Subsequent invocation of any resume function on the resulting continuation will produce an [IllegalStateException](../kotlin/-illegal-state-exception/index#kotlin.IllegalStateException). **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <R, T> (suspend R.() -> T).createCoroutine(     receiver: R,     completion: Continuation<T> ): Continuation<Unit> ``` Creates a coroutine with receiver type [R](create-coroutine#R) and result type [T](create-coroutine#T). This function creates a new, fresh instance of suspendable computation every time it is invoked. To start executing the created coroutine, invoke `resume(Unit)` on the returned [Continuation](-continuation/index) instance. The [completion](create-coroutine#kotlin.coroutines%24createCoroutine(kotlin.coroutines.SuspendFunction1((kotlin.coroutines.createCoroutine.R,%20kotlin.coroutines.createCoroutine.T)),%20kotlin.coroutines.createCoroutine.R,%20kotlin.coroutines.Continuation((kotlin.coroutines.createCoroutine.T)))/completion) continuation is invoked when the coroutine completes with a result or an exception. Subsequent invocation of any resume function on the resulting continuation will produce an [IllegalStateException](../kotlin/-illegal-state-exception/index#kotlin.IllegalStateException).
programming_docs
kotlin startCoroutine startCoroutine ============== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [startCoroutine](start-coroutine) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> (suspend () -> T).startCoroutine(     completion: Continuation<T>) ``` Starts a coroutine without a receiver and with result type [T](start-coroutine#T). This function creates and starts a new, fresh instance of suspendable computation every time it is invoked. The [completion](start-coroutine#kotlin.coroutines%24startCoroutine(kotlin.coroutines.SuspendFunction0((kotlin.coroutines.startCoroutine.T)),%20kotlin.coroutines.Continuation((kotlin.coroutines.startCoroutine.T)))/completion) continuation is invoked when the coroutine completes with a result or an exception. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <R, T> (suspend R.() -> T).startCoroutine(     receiver: R,     completion: Continuation<T>) ``` Starts a coroutine with receiver type [R](start-coroutine#R) and result type [T](start-coroutine#T). This function creates and starts a new, fresh instance of suspendable computation every time it is invoked. The [completion](start-coroutine#kotlin.coroutines%24startCoroutine(kotlin.coroutines.SuspendFunction1((kotlin.coroutines.startCoroutine.R,%20kotlin.coroutines.startCoroutine.T)),%20kotlin.coroutines.startCoroutine.R,%20kotlin.coroutines.Continuation((kotlin.coroutines.startCoroutine.T)))/completion) continuation is invoked when the coroutine completes with a result or an exception. kotlin Continuation Continuation ============ [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [Continuation](-continuation) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <T> Continuation(     context: CoroutineContext,     crossinline resumeWith: (Result<T>) -> Unit ): Continuation<T> ``` Creates a [Continuation](-continuation/index) instance with the given [context](-continuation#kotlin.coroutines%24Continuation(kotlin.coroutines.CoroutineContext,%20kotlin.Function1((kotlin.Result((kotlin.coroutines.Continuation.T)),%20kotlin.Unit)))/context) and implementation of [resumeWith](-continuation#kotlin.coroutines%24Continuation(kotlin.coroutines.CoroutineContext,%20kotlin.Function1((kotlin.Result((kotlin.coroutines.Continuation.T)),%20kotlin.Unit)))/resumeWith) method. kotlin minusPolymorphicKey minusPolymorphicKey =================== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [minusPolymorphicKey](minus-polymorphic-key) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalStdlibApi fun Element.minusPolymorphicKey(     key: Key<*> ): CoroutineContext ``` Returns empty coroutine context if the element is associated with the given [key](minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) in a polymorphic manner or `null` otherwise. This method returns empty context if either [Element.key](-coroutine-context/-element/key) is equal to the given [key](minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) or if the [key](minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) is associated with [Element.key](-coroutine-context/-element/key) via [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index). See [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index) for the example of usage. kotlin getPolymorphicElement getPolymorphicElement ===================== [kotlin-stdlib](../../../../../index) / [kotlin.coroutines](index) / [getPolymorphicElement](get-polymorphic-element) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalStdlibApi fun <E : Element> Element.getPolymorphicElement(     key: Key<E> ): E? ``` Returns the current element if it is associated with the given [key](get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) in a polymorphic manner or `null` otherwise. This method returns non-null value if either [Element.key](-coroutine-context/-element/key) is equal to the given [key](get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) or if the [key](get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) is associated with [Element.key](-coroutine-context/-element/key) via [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index). See [AbstractCoroutineContextKey](-abstract-coroutine-context-key/index) for the example of usage. kotlin RestrictsSuspension RestrictsSuspension =================== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [RestrictsSuspension](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @Target([AnnotationTarget.CLASS]) annotation class RestrictsSuspension ``` Classes and interfaces marked with this annotation are restricted when used as receivers for extension `suspend` functions. These `suspend` extensions can only invoke other member or extension `suspend` functions on this particular receiver and are restricted from calling arbitrary suspension functions. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Classes and interfaces marked with this annotation are restricted when used as receivers for extension `suspend` functions. These `suspend` extensions can only invoke other member or extension `suspend` functions on this particular receiver and are restricted from calling arbitrary suspension functions. ``` RestrictsSuspension() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [RestrictsSuspension](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` RestrictsSuspension() ``` Classes and interfaces marked with this annotation are restricted when used as receivers for extension `suspend` functions. These `suspend` extensions can only invoke other member or extension `suspend` functions on this particular receiver and are restricted from calling arbitrary suspension functions. kotlin AbstractCoroutineContextKey AbstractCoroutineContextKey =========================== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [AbstractCoroutineContextKey](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalStdlibApi abstract class AbstractCoroutineContextKey<B : Element, E : B> :      Key<E> ``` Base class for [CoroutineContext.Key](../-coroutine-context/-key) associated with polymorphic [CoroutineContext.Element](../-coroutine-context/-element/index) implementation. Polymorphic element implementation implies delegating its [get](../-coroutine-context/-element/get) and [minusKey](../-coroutine-context/-element/minus-key) to [getPolymorphicElement](../get-polymorphic-element) and [minusPolymorphicKey](../minus-polymorphic-key) respectively. Polymorphic elements can be extracted from the coroutine context using both element key and its supertype key. Example of polymorphic elements: ``` open class BaseElement : CoroutineContext.Element { companion object Key : CoroutineContext.Key<BaseElement> override val key: CoroutineContext.Key<*> get() = Key // It is important to use getPolymorphicKey and minusPolymorphicKey override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E? = getPolymorphicElement(key) override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext = minusPolymorphicKey(key) } class DerivedElement : BaseElement() { companion object Key : AbstractCoroutineContextKey<BaseElement, DerivedElement>(BaseElement, { it as? DerivedElement }) } // Now it is possible to query both `BaseElement` and `DerivedElement` someContext[BaseElement] // Returns BaseElement?, non-null both for BaseElement and DerivedElement instances someContext[DerivedElement] // Returns DerivedElement?, non-null only for DerivedElement instance ``` Parameters ---------- `B` - base class of a polymorphic element `baseKey` - an instance of base key `E` - element type associated with the current key `safeCast` - a function that can safely cast abstract [CoroutineContext.Element](../-coroutine-context/-element/index) to the concrete [E](index#E) type and return the element if it is a subtype of [E](index#E) or `null` otherwise. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Base class for [CoroutineContext.Key](../-coroutine-context/-key) associated with polymorphic [CoroutineContext.Element](../-coroutine-context/-element/index) implementation. Polymorphic element implementation implies delegating its [get](../-coroutine-context/-element/get) and [minusKey](../-coroutine-context/-element/minus-key) to [getPolymorphicElement](../get-polymorphic-element) and [minusPolymorphicKey](../minus-polymorphic-key) respectively. ``` AbstractCoroutineContextKey(     baseKey: Key<B>,     safeCast: (element: Element) -> E?) ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [AbstractCoroutineContextKey](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` AbstractCoroutineContextKey(     baseKey: Key<B>,     safeCast: (element: Element) -> E?) ``` Base class for [CoroutineContext.Key](../-coroutine-context/-key) associated with polymorphic [CoroutineContext.Element](../-coroutine-context/-element/index) implementation. Polymorphic element implementation implies delegating its [get](../-coroutine-context/-element/get) and [minusKey](../-coroutine-context/-element/minus-key) to [getPolymorphicElement](../get-polymorphic-element) and [minusPolymorphicKey](../minus-polymorphic-key) respectively. Polymorphic elements can be extracted from the coroutine context using both element key and its supertype key. Example of polymorphic elements: ``` open class BaseElement : CoroutineContext.Element { companion object Key : CoroutineContext.Key<BaseElement> override val key: CoroutineContext.Key<*> get() = Key // It is important to use getPolymorphicKey and minusPolymorphicKey override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E? = getPolymorphicElement(key) override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext = minusPolymorphicKey(key) } class DerivedElement : BaseElement() { companion object Key : AbstractCoroutineContextKey<BaseElement, DerivedElement>(BaseElement, { it as? DerivedElement }) } // Now it is possible to query both `BaseElement` and `DerivedElement` someContext[BaseElement] // Returns BaseElement?, non-null both for BaseElement and DerivedElement instances someContext[DerivedElement] // Returns DerivedElement?, non-null only for DerivedElement instance ``` Parameters ---------- `B` - base class of a polymorphic element `baseKey` - an instance of base key `E` - element type associated with the current key `safeCast` - a function that can safely cast abstract [CoroutineContext.Element](../-coroutine-context/-element/index) to the concrete [E](index#E) type and return the element if it is a subtype of [E](index#E) or `null` otherwise. kotlin Continuation Continuation ============ [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [Continuation](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` interface Continuation<in T> ``` Interface representing a continuation after a suspension point that returns a value of type `T`. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <context> The context of the coroutine that corresponds to this continuation. ``` abstract val context: CoroutineContext ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [resumeWith](resume-with) Resumes the execution of the corresponding coroutine passing a successful or failed [result](resume-with#kotlin.coroutines.Continuation%24resumeWith(kotlin.Result((kotlin.coroutines.Continuation.T)))/result) as the return value of the last suspension point. ``` abstract fun resumeWith(result: Result<T>) ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [resume](../resume) Resumes the execution of the corresponding coroutine passing [value](../resume#kotlin.coroutines%24resume(kotlin.coroutines.Continuation((kotlin.coroutines.resume.T)),%20kotlin.coroutines.resume.T)/value) as the return value of the last suspension point. ``` fun <T> Continuation<T>.resume(value: T) ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [resumeWithException](../resume-with-exception) Resumes the execution of the corresponding coroutine so that the [exception](../resume-with-exception#kotlin.coroutines%24resumeWithException(kotlin.coroutines.Continuation((kotlin.coroutines.resumeWithException.T)),%20kotlin.Throwable)/exception) is re-thrown right after the last suspension point. ``` fun <T> Continuation<T>.resumeWithException(     exception: Throwable) ``` kotlin context context ======= [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [Continuation](index) / <context> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val context: CoroutineContext ``` The context of the coroutine that corresponds to this continuation. kotlin resumeWith resumeWith ========== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [Continuation](index) / [resumeWith](resume-with) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun resumeWith(result: Result<T>) ``` Resumes the execution of the corresponding coroutine passing a successful or failed [result](resume-with#kotlin.coroutines.Continuation%24resumeWith(kotlin.Result((kotlin.coroutines.Continuation.T)))/result) as the return value of the last suspension point. kotlin AbstractCoroutineContextElement AbstractCoroutineContextElement =============================== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [AbstractCoroutineContextElement](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` abstract class AbstractCoroutineContextElement : Element ``` Base class for [CoroutineContext.Element](../-coroutine-context/-element/index) implementations. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Base class for [CoroutineContext.Element](../-coroutine-context/-element/index) implementations. ``` AbstractCoroutineContextElement(key: Key<*>) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <key> A key of this coroutine context element. ``` open val key: Key<*> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getPolymorphicElement](../get-polymorphic-element) Returns the current element if it is associated with the given [key](../get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) in a polymorphic manner or `null` otherwise. This method returns non-null value if either [Element.key](../-coroutine-context/-element/key) is equal to the given [key](../get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) or if the [key](../get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) is associated with [Element.key](../-coroutine-context/-element/key) via [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index). See [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index) for the example of usage. ``` fun <E : Element> Element.getPolymorphicElement(     key: Key<E> ): E? ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [minusPolymorphicKey](../minus-polymorphic-key) Returns empty coroutine context if the element is associated with the given [key](../minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) in a polymorphic manner or `null` otherwise. This method returns empty context if either [Element.key](../-coroutine-context/-element/key) is equal to the given [key](../minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) or if the [key](../minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) is associated with [Element.key](../-coroutine-context/-element/key) via [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index). See [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index) for the example of usage. ``` fun Element.minusPolymorphicKey(     key: Key<*> ): CoroutineContext ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [AbstractCoroutineContextElement](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` AbstractCoroutineContextElement(key: Key<*>) ``` Base class for [CoroutineContext.Element](../-coroutine-context/-element/index) implementations. kotlin key key === [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [AbstractCoroutineContextElement](index) / <key> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open val key: Key<*> ``` A key of this coroutine context element. kotlin CoroutineContext CoroutineContext ================ [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [CoroutineContext](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` interface CoroutineContext ``` Persistent context for the coroutine. It is an indexed set of [Element](-element/index) instances. An indexed set is a mix between a set and a map. Every element in this set has a unique [Key](-key). Types ----- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Element](-element/index) An element of the [CoroutineContext](index). An element of the coroutine context is a singleton context by itself. ``` interface Element : CoroutineContext ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Key](-key) Key for the elements of [CoroutineContext](index). [E](-key#E) is a type of element with this key. ``` interface Key<E : Element> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <fold> Accumulates entries of this context starting with [initial](fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/initial) value and applying [operation](fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/operation) from left to right to current accumulator value and each element of this context. ``` abstract fun <R> fold(     initial: R,     operation: (R, Element) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the element with the given [key](get#kotlin.coroutines.CoroutineContext%24get(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.get.E)))/key) from this context or `null`. ``` abstract operator fun <E : Element> get(key: Key<E>): E? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusKey](minus-key) Returns a context containing elements from this context, but without an element with the specified [key](minus-key#kotlin.coroutines.CoroutineContext%24minusKey(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key). ``` abstract fun minusKey(key: Key<*>): CoroutineContext ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Returns a context containing elements from this context and elements from other [context](plus#kotlin.coroutines.CoroutineContext%24plus(kotlin.coroutines.CoroutineContext)/context). The elements from this context with the same key as in the other one are dropped. ``` open operator fun plus(     context: CoroutineContext ): CoroutineContext ``` Inheritors ---------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [EmptyCoroutineContext](../-empty-coroutine-context/index) An empty coroutine context. ``` object EmptyCoroutineContext : CoroutineContext, Serializable ```
programming_docs
kotlin Key Key === [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [CoroutineContext](index) / [Key](-key) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` interface Key<E : Element> ``` Key for the elements of [CoroutineContext](index). [E](-key#E) is a type of element with this key. kotlin minusKey minusKey ======== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [CoroutineContext](index) / [minusKey](minus-key) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun minusKey(key: Key<*>): CoroutineContext ``` Returns a context containing elements from this context, but without an element with the specified [key](minus-key#kotlin.coroutines.CoroutineContext%24minusKey(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key). kotlin fold fold ==== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [CoroutineContext](index) / <fold> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun <R> fold(     initial: R,     operation: (R, Element) -> R ): R ``` Accumulates entries of this context starting with [initial](fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/initial) value and applying [operation](fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/operation) from left to right to current accumulator value and each element of this context. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [CoroutineContext](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open operator fun plus(     context: CoroutineContext ): CoroutineContext ``` Returns a context containing elements from this context and elements from other [context](plus#kotlin.coroutines.CoroutineContext%24plus(kotlin.coroutines.CoroutineContext)/context). The elements from this context with the same key as in the other one are dropped. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [CoroutineContext](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract operator fun <E : Element> get(key: Key<E>): E? ``` Returns the element with the given [key](get#kotlin.coroutines.CoroutineContext%24get(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.get.E)))/key) from this context or `null`. kotlin Element Element ======= [kotlin-stdlib](../../../../../../../index) / [kotlin.coroutines](../../index) / [CoroutineContext](../index) / [Element](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` interface Element : CoroutineContext ``` An element of the [CoroutineContext](../index). An element of the coroutine context is a singleton context by itself. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <key> A key of this coroutine context element. ``` abstract val key: Key<*> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <fold> Accumulates entries of this context starting with [initial](../fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/initial) value and applying [operation](../fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/operation) from left to right to current accumulator value and each element of this context. ``` open fun <R> fold(     initial: R,     operation: (R, Element) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the element with the given [key](../get#kotlin.coroutines.CoroutineContext%24get(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.get.E)))/key) from this context or `null`. ``` open operator fun <E : Element> get(key: Key<E>): E? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusKey](minus-key) Returns a context containing elements from this context, but without an element with the specified [key](../minus-key#kotlin.coroutines.CoroutineContext%24minusKey(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key). ``` open fun minusKey(key: Key<*>): CoroutineContext ``` kotlin minusKey minusKey ======== [kotlin-stdlib](../../../../../../../index) / [kotlin.coroutines](../../index) / [CoroutineContext](../index) / [Element](index) / [minusKey](minus-key) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun minusKey(key: Key<*>): CoroutineContext ``` Returns a context containing elements from this context, but without an element with the specified [key](../minus-key#kotlin.coroutines.CoroutineContext%24minusKey(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key). kotlin key key === [kotlin-stdlib](../../../../../../../index) / [kotlin.coroutines](../../index) / [CoroutineContext](../index) / [Element](index) / <key> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val key: Key<*> ``` A key of this coroutine context element. kotlin fold fold ==== [kotlin-stdlib](../../../../../../../index) / [kotlin.coroutines](../../index) / [CoroutineContext](../index) / [Element](index) / <fold> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun <R> fold(     initial: R,     operation: (R, Element) -> R ): R ``` Accumulates entries of this context starting with [initial](../fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/initial) value and applying [operation](../fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/operation) from left to right to current accumulator value and each element of this context. kotlin get get === [kotlin-stdlib](../../../../../../../index) / [kotlin.coroutines](../../index) / [CoroutineContext](../index) / [Element](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open operator fun <E : Element> get(key: Key<E>): E? ``` Returns the element with the given [key](../get#kotlin.coroutines.CoroutineContext%24get(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.get.E)))/key) from this context or `null`. kotlin EmptyCoroutineContext EmptyCoroutineContext ===================== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [EmptyCoroutineContext](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` object EmptyCoroutineContext : CoroutineContext, Serializable ``` An empty coroutine context. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <fold> Accumulates entries of this context starting with [initial](../-coroutine-context/fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/initial) value and applying [operation](../-coroutine-context/fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/operation) from left to right to current accumulator value and each element of this context. ``` fun <R> fold(initial: R, operation: (R, Element) -> R): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the element with the given [key](../-coroutine-context/get#kotlin.coroutines.CoroutineContext%24get(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.get.E)))/key) from this context or `null`. ``` fun <E : Element> get(key: Key<E>): E? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hashCode](hash-code) Returns a hash code value for the object. The general contract of `hashCode` is: ``` fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusKey](minus-key) Returns a context containing elements from this context, but without an element with the specified [key](../-coroutine-context/minus-key#kotlin.coroutines.CoroutineContext%24minusKey(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key). ``` fun minusKey(key: Key<*>): CoroutineContext ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Returns a context containing elements from this context and elements from other [context](../-coroutine-context/plus#kotlin.coroutines.CoroutineContext%24plus(kotlin.coroutines.CoroutineContext)/context). The elements from this context with the same key as in the other one are dropped. ``` fun plus(context: CoroutineContext): CoroutineContext ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns a string representation of the object. ``` fun toString(): String ``` kotlin minusKey minusKey ======== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [EmptyCoroutineContext](index) / [minusKey](minus-key) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun minusKey(key: Key<*>): CoroutineContext ``` Returns a context containing elements from this context, but without an element with the specified [key](../-coroutine-context/minus-key#kotlin.coroutines.CoroutineContext%24minusKey(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key). kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [EmptyCoroutineContext](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun hashCode(): Int ``` Returns a hash code value for the object. The general contract of `hashCode` is: * Whenever it is invoked on the same object more than once, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. * If two objects are equal according to the `equals()` method, then calling the `hashCode` method on each of the two objects must produce the same integer result. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [EmptyCoroutineContext](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toString(): String ``` Returns a string representation of the object. kotlin fold fold ==== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [EmptyCoroutineContext](index) / <fold> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <R> fold(initial: R, operation: (R, Element) -> R): R ``` Accumulates entries of this context starting with [initial](../-coroutine-context/fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/initial) value and applying [operation](../-coroutine-context/fold#kotlin.coroutines.CoroutineContext%24fold(kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.Function2((kotlin.coroutines.CoroutineContext.fold.R,%20kotlin.coroutines.CoroutineContext.Element,%20)))/operation) from left to right to current accumulator value and each element of this context. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [EmptyCoroutineContext](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun plus(context: CoroutineContext): CoroutineContext ``` Returns a context containing elements from this context and elements from other [context](../-coroutine-context/plus#kotlin.coroutines.CoroutineContext%24plus(kotlin.coroutines.CoroutineContext)/context). The elements from this context with the same key as in the other one are dropped. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [EmptyCoroutineContext](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <E : Element> get(key: Key<E>): E? ``` Returns the element with the given [key](../-coroutine-context/get#kotlin.coroutines.CoroutineContext%24get(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.get.E)))/key) from this context or `null`. kotlin releaseInterceptedContinuation releaseInterceptedContinuation ============================== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [ContinuationInterceptor](index) / [releaseInterceptedContinuation](release-intercepted-continuation) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun releaseInterceptedContinuation(     continuation: Continuation<*>) ``` Invoked for the continuation instance returned by [interceptContinuation](intercept-continuation) when the original continuation completes and will not be used anymore. This function is invoked only if [interceptContinuation](intercept-continuation) had returned a different continuation instance from the one it was invoked with. Default implementation does nothing. Parameters ---------- `continuation` - Continuation instance returned by this interceptor's [interceptContinuation](intercept-continuation) invocation. kotlin ContinuationInterceptor ContinuationInterceptor ======================= [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [ContinuationInterceptor](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` interface ContinuationInterceptor : Element ``` Marks coroutine context element that intercepts coroutine continuations. The coroutines framework uses [ContinuationInterceptor.Key](-key) to retrieve the interceptor and intercepts all coroutine continuations with [interceptContinuation](intercept-continuation) invocations. [ContinuationInterceptor](index) behaves like a [polymorphic element](../-abstract-coroutine-context-key/index), meaning that its implementation delegates [get](../-coroutine-context/-element/get) and [minusKey](../-coroutine-context/-element/minus-key) to [getPolymorphicElement](../get-polymorphic-element) and [minusPolymorphicKey](../minus-polymorphic-key) respectively. [ContinuationInterceptor](index) subtypes can be extracted from the coroutine context using either [ContinuationInterceptor.Key](-key) or subtype key if it extends [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index). Types ----- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Key](-key) The key that defines *the* context interceptor. ``` companion object Key : Key<ContinuationInterceptor> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the element with the given [key](../-coroutine-context/get#kotlin.coroutines.CoroutineContext%24get(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.get.E)))/key) from this context or `null`. ``` open operator fun <E : Element> get(key: Key<E>): E? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [interceptContinuation](intercept-continuation) Returns continuation that wraps the original [continuation](intercept-continuation#kotlin.coroutines.ContinuationInterceptor%24interceptContinuation(kotlin.coroutines.Continuation((kotlin.coroutines.ContinuationInterceptor.interceptContinuation.T)))/continuation), thus intercepting all resumptions. This function is invoked by coroutines framework when needed and the resulting continuations are cached internally per each instance of the original [continuation](intercept-continuation#kotlin.coroutines.ContinuationInterceptor%24interceptContinuation(kotlin.coroutines.Continuation((kotlin.coroutines.ContinuationInterceptor.interceptContinuation.T)))/continuation). ``` abstract fun <T> interceptContinuation(     continuation: Continuation<T> ): Continuation<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusKey](minus-key) Returns a context containing elements from this context, but without an element with the specified [key](../-coroutine-context/minus-key#kotlin.coroutines.CoroutineContext%24minusKey(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key). ``` open fun minusKey(key: Key<*>): CoroutineContext ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [releaseInterceptedContinuation](release-intercepted-continuation) Invoked for the continuation instance returned by [interceptContinuation](intercept-continuation) when the original continuation completes and will not be used anymore. This function is invoked only if [interceptContinuation](intercept-continuation) had returned a different continuation instance from the one it was invoked with. ``` open fun releaseInterceptedContinuation(     continuation: Continuation<*>) ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getPolymorphicElement](../get-polymorphic-element) Returns the current element if it is associated with the given [key](../get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) in a polymorphic manner or `null` otherwise. This method returns non-null value if either [Element.key](../-coroutine-context/-element/key) is equal to the given [key](../get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) or if the [key](../get-polymorphic-element#kotlin.coroutines%24getPolymorphicElement(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.getPolymorphicElement.E)))/key) is associated with [Element.key](../-coroutine-context/-element/key) via [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index). See [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index) for the example of usage. ``` fun <E : Element> Element.getPolymorphicElement(     key: Key<E> ): E? ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [minusPolymorphicKey](../minus-polymorphic-key) Returns empty coroutine context if the element is associated with the given [key](../minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) in a polymorphic manner or `null` otherwise. This method returns empty context if either [Element.key](../-coroutine-context/-element/key) is equal to the given [key](../minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) or if the [key](../minus-polymorphic-key#kotlin.coroutines%24minusPolymorphicKey(kotlin.coroutines.CoroutineContext.Element,%20kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key) is associated with [Element.key](../-coroutine-context/-element/key) via [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index). See [AbstractCoroutineContextKey](../-abstract-coroutine-context-key/index) for the example of usage. ``` fun Element.minusPolymorphicKey(     key: Key<*> ): CoroutineContext ```
programming_docs
kotlin Key Key === [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [ContinuationInterceptor](index) / [Key](-key) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` companion object Key : Key<ContinuationInterceptor> ``` The key that defines *the* context interceptor. kotlin minusKey minusKey ======== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [ContinuationInterceptor](index) / [minusKey](minus-key) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun minusKey(key: Key<*>): CoroutineContext ``` Returns a context containing elements from this context, but without an element with the specified [key](../-coroutine-context/minus-key#kotlin.coroutines.CoroutineContext%24minusKey(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.Element)))/key). kotlin interceptContinuation interceptContinuation ===================== [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [ContinuationInterceptor](index) / [interceptContinuation](intercept-continuation) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun <T> interceptContinuation(     continuation: Continuation<T> ): Continuation<T> ``` Returns continuation that wraps the original [continuation](intercept-continuation#kotlin.coroutines.ContinuationInterceptor%24interceptContinuation(kotlin.coroutines.Continuation((kotlin.coroutines.ContinuationInterceptor.interceptContinuation.T)))/continuation), thus intercepting all resumptions. This function is invoked by coroutines framework when needed and the resulting continuations are cached internally per each instance of the original [continuation](intercept-continuation#kotlin.coroutines.ContinuationInterceptor%24interceptContinuation(kotlin.coroutines.Continuation((kotlin.coroutines.ContinuationInterceptor.interceptContinuation.T)))/continuation). This function may simply return original [continuation](intercept-continuation#kotlin.coroutines.ContinuationInterceptor%24interceptContinuation(kotlin.coroutines.Continuation((kotlin.coroutines.ContinuationInterceptor.interceptContinuation.T)))/continuation) if it does not want to intercept this particular continuation. When the original [continuation](intercept-continuation#kotlin.coroutines.ContinuationInterceptor%24interceptContinuation(kotlin.coroutines.Continuation((kotlin.coroutines.ContinuationInterceptor.interceptContinuation.T)))/continuation) completes, coroutine framework invokes [releaseInterceptedContinuation](release-intercepted-continuation) with the resulting continuation if it was intercepted, that is if `interceptContinuation` had previously returned a different continuation instance. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.coroutines](../index) / [ContinuationInterceptor](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open operator fun <E : Element> get(key: Key<E>): E? ``` Returns the element with the given [key](../-coroutine-context/get#kotlin.coroutines.CoroutineContext%24get(kotlin.coroutines.CoroutineContext.Key((kotlin.coroutines.CoroutineContext.get.E)))/key) from this context or `null`. kotlin sortedWith sortedWith ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [sortedWith](sorted-with) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.sortedWith(     comparator: Comparator<in T> ): Sequence<T> ``` Returns a sequence that yields elements of this sequence sorted according to the specified [comparator](sorted-with#kotlin.sequences%24sortedWith(kotlin.sequences.Sequence((kotlin.sequences.sortedWith.T)),%20kotlin.Comparator((kotlin.sequences.sortedWith.T)))/comparator). The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. The operation is *intermediate* and *stateful*. kotlin joinTo joinTo ====== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [joinTo](join-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, A : Appendable> Sequence<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` Appends the string from all the elements separated using [separator](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. If the collection could be huge, you can specify a non-negative value of [limit](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/limit), in which case only the first [limit](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/limit) elements will be appended, followed by the [truncated](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/truncated) string (which defaults to "..."). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sb = StringBuilder("An existing string and a list: ") val numbers = listOf(1, 2, 3) println(numbers.joinTo(sb, prefix = "[", postfix = "]").toString()) // An existing string and a list: [1, 2, 3] val lotOfNumbers: Iterable<Int> = 1..100 val firstNumbers = StringBuilder("First five numbers: ") println(lotOfNumbers.joinTo(firstNumbers, limit = 5).toString()) // First five numbers: 1, 2, 3, 4, 5, ... //sampleEnd } ``` kotlin foldIndexed foldIndexed =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [foldIndexed](fold-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Sequence<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` Accumulates value starting with [initial](fold-indexed#kotlin.sequences%24foldIndexed(kotlin.sequences.Sequence((kotlin.sequences.foldIndexed.T)),%20kotlin.sequences.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.foldIndexed.R,%20kotlin.sequences.foldIndexed.T,%20)))/initial) value and applying [operation](fold-indexed#kotlin.sequences%24foldIndexed(kotlin.sequences.Sequence((kotlin.sequences.foldIndexed.T)),%20kotlin.sequences.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.foldIndexed.R,%20kotlin.sequences.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. Returns the specified [initial](fold-indexed#kotlin.sequences%24foldIndexed(kotlin.sequences.Sequence((kotlin.sequences.foldIndexed.T)),%20kotlin.sequences.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.foldIndexed.R,%20kotlin.sequences.foldIndexed.T,%20)))/initial) value if the sequence is empty. Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. The operation is *terminal*. kotlin all all === [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <all> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.all(     predicate: (T) -> Boolean ): Boolean ``` Returns `true` if all elements match the given [predicate](all#kotlin.sequences%24all(kotlin.sequences.Sequence((kotlin.sequences.all.T)),%20kotlin.Function1((kotlin.sequences.all.T,%20kotlin.Boolean)))/predicate). Note that if the sequence contains no elements, the function returns `true` because there are no elements in it that *do not* match the predicate. See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.all { isEven(it) } is ${zeroToTen.all { isEven(it) }}") // false println("zeroToTen.all(isEven) is ${zeroToTen.all(isEven)}") // false val evens = zeroToTen.map { it * 2 } println("evens.all { isEven(it) } is ${evens.all { isEven(it) }}") // true val emptyList = emptyList<Int>() println("emptyList.all { false } is ${emptyList.all { false }}") // true //sampleEnd } ``` kotlin reduceIndexedOrNull reduceIndexedOrNull =================== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [reduceIndexedOrNull](reduce-indexed-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Sequence<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` Accumulates value starting with the first element and applying [operation](reduce-indexed-or-null#kotlin.sequences%24reduceIndexedOrNull(kotlin.sequences.Sequence((kotlin.sequences.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.reduceIndexedOrNull.S,%20kotlin.sequences.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. Returns `null` if the sequence is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceOrNull { acc, string -> acc + string }) // abcd println(strings.reduceIndexedOrNull { index, acc, string -> acc + string + index }) // ab1c2d3 println(emptyList<String>().reduceOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. The operation is *terminal*. kotlin single single ====== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <single> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.single(): T ``` Returns the single element, or throws an exception if the sequence is empty or has more than one element. The operation is *terminal*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.single(     predicate: (T) -> Boolean ): T ``` Returns the single element matching the given [predicate](single#kotlin.sequences%24single(kotlin.sequences.Sequence((kotlin.sequences.single.T)),%20kotlin.Function1((kotlin.sequences.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. The operation is *terminal*. kotlin reduceOrNull reduceOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [reduceOrNull](reduce-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <S, T : S> Sequence<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` Accumulates value starting with the first element and applying [operation](reduce-or-null#kotlin.sequences%24reduceOrNull(kotlin.sequences.Sequence((kotlin.sequences.reduceOrNull.T)),%20kotlin.Function2((kotlin.sequences.reduceOrNull.S,%20kotlin.sequences.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. Returns `null` if the sequence is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceOrNull { acc, string -> acc + string }) // abcd println(strings.reduceIndexedOrNull { index, acc, string -> acc + string + index }) // ab1c2d3 println(emptyList<String>().reduceOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. The operation is *terminal*. kotlin runningReduce runningReduce ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [runningReduce](running-reduce) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <S, T : S> Sequence<T>.runningReduce(     operation: (acc: S, T) -> S ): Sequence<S> ``` Returns a sequence containing successive accumulation values generated by applying [operation](running-reduce#kotlin.sequences%24runningReduce(kotlin.sequences.Sequence((kotlin.sequences.runningReduce.T)),%20kotlin.Function2((kotlin.sequences.runningReduce.S,%20kotlin.sequences.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this sequence. Note that `acc` value passed to [operation](running-reduce#kotlin.sequences%24runningReduce(kotlin.sequences.Sequence((kotlin.sequences.runningReduce.T)),%20kotlin.Function2((kotlin.sequences.runningReduce.S,%20kotlin.sequences.runningReduce.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and the element, and calculates the next accumulator value. The operation is *intermediate* and *stateless*. kotlin ifEmpty ifEmpty ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [ifEmpty](if-empty) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Sequence<T>.ifEmpty(     defaultValue: () -> Sequence<T> ): Sequence<T> ``` Returns a sequence that iterates through the elements either of this sequence or, if this sequence turns out to be empty, of the sequence returned by [defaultValue](if-empty#kotlin.sequences%24ifEmpty(kotlin.sequences.Sequence((kotlin.sequences.ifEmpty.T)),%20kotlin.Function0((kotlin.sequences.Sequence((kotlin.sequences.ifEmpty.T)))))/defaultValue) function. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val empty = emptySequence<Int>() val emptyOrDefault = empty.ifEmpty { sequenceOf("default") } println(emptyOrDefault.toList()) // [default] val nonEmpty = sequenceOf("value") val nonEmptyOrDefault = nonEmpty.ifEmpty { sequenceOf("default") } println(nonEmptyOrDefault.toList()) // [value] //sampleEnd } ``` kotlin filterIsInstanceTo filterIsInstanceTo ================== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterIsInstanceTo](filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <reified R, C : MutableCollection<in R>> Sequence<*>.filterIsInstanceTo(     destination: C ): C ``` Appends all elements that are instances of specified type parameter R to the given [destination](filter-is-instance-to#kotlin.sequences%24filterIsInstanceTo(kotlin.sequences.Sequence((kotlin.Any?)),%20kotlin.sequences.filterIsInstanceTo.C)/destination). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart open class Animal(val name: String) { override fun toString(): String { return name } } class Dog(name: String): Animal(name) class Cat(name: String): Animal(name) val animals: List<Animal> = listOf(Cat("Scratchy"), Dog("Poochie")) val cats = mutableListOf<Cat>() println(cats) // [] animals.filterIsInstanceTo<Cat, MutableList<Cat>>(cats) println(cats) // [Scratchy] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0) ``` fun <C : MutableCollection<in R>, R> Sequence<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` Appends all elements that are instances of specified class to the given [destination](filter-is-instance-to#kotlin.sequences%24filterIsInstanceTo(kotlin.sequences.Sequence((kotlin.Any?)),%20kotlin.sequences.filterIsInstanceTo.C,%20java.lang.Class((kotlin.sequences.filterIsInstanceTo.R)))/destination). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart open class Animal(val name: String) { override fun toString(): String { return name } } class Dog(name: String): Animal(name) class Cat(name: String): Animal(name) val animals: List<Animal> = listOf(Cat("Scratchy"), Dog("Poochie")) val cats = mutableListOf<Cat>() println(cats) // [] animals.filterIsInstanceTo(cats, Cat::class.java) println(cats) // [Scratchy] //sampleEnd } ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.contains(element: T): Boolean ``` Returns `true` if [element](contains#kotlin.sequences%24contains(kotlin.sequences.Sequence((kotlin.sequences.contains.T)),%20kotlin.sequences.contains.T)/element) is found in the sequence. The operation is *terminal*. kotlin mapNotNull mapNotNull ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [mapNotNull](map-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, R : Any> Sequence<T>.mapNotNull(     transform: (T) -> R? ): Sequence<R> ``` Returns a sequence containing only the non-null results of applying the given [transform](map-not-null#kotlin.sequences%24mapNotNull(kotlin.sequences.Sequence((kotlin.sequences.mapNotNull.T)),%20kotlin.Function1((kotlin.sequences.mapNotNull.T,%20kotlin.sequences.mapNotNull.R?)))/transform) function to each element in the original sequence. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings: List<String> = listOf("12a", "45", "", "3") val ints: List<Int> = strings.mapNotNull { it.toIntOrNull() } println(ints) // [45, 3] println(ints.sum()) // 48 //sampleEnd } ```
programming_docs
kotlin associateByTo associateByTo ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [associateByTo](associate-by-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, M : MutableMap<in K, in T>> Sequence<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)))/keySelector) function applied to each element of the given sequence and value is the element itself. If any two elements would have the same key returned by [keySelector](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)))/keySelector) the last one gets added to the map. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = mutableMapOf<String, Person>() println("byLastName.isEmpty() is ${byLastName.isEmpty()}") // true scientists.associateByTo(byLastName) { it.lastName } println("byLastName.isNotEmpty() is ${byLastName.isNotEmpty()}") // true // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace Hopper, Bernoulli=Johann Bernoulli} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` Populates and returns the [destination](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/valueTransform) function applied to elements of the given sequence. If any two elements would have the same key returned by [keySelector](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/keySelector) the last one gets added to the map. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = mutableMapOf<String, String>() println("byLastName.isEmpty() is ${byLastName.isEmpty()}") // true scientists.associateByTo(byLastName, { it.lastName }, { it.firstName} ) println("byLastName.isNotEmpty() is ${byLastName.isNotEmpty()}") // true // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace, Bernoulli=Johann} //sampleEnd } ``` kotlin any any === [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <any> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.any(): Boolean ``` Returns `true` if sequence has at least one element. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.any() is ${emptyList.any()}") // false val nonEmptyList = listOf(1, 2, 3) println("nonEmptyList.any() is ${nonEmptyList.any()}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.any(     predicate: (T) -> Boolean ): Boolean ``` Returns `true` if at least one element matches the given [predicate](any#kotlin.sequences%24any(kotlin.sequences.Sequence((kotlin.sequences.any.T)),%20kotlin.Function1((kotlin.sequences.any.T,%20kotlin.Boolean)))/predicate). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.any { isEven(it) } is ${zeroToTen.any { isEven(it) }}") // true println("zeroToTen.any(isEven) is ${zeroToTen.any(isEven)}") // true val odds = zeroToTen.map { it * 2 + 1 } println("odds.any { isEven(it) } is ${odds.any { isEven(it) }}") // false val emptyList = emptyList<Int>() println("emptyList.any { true } is ${emptyList.any { true }}") // false //sampleEnd } ``` kotlin map map === [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <map> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, R> Sequence<T>.map(transform: (T) -> R): Sequence<R> ``` Returns a sequence containing the results of applying the given [transform](map#kotlin.sequences%24map(kotlin.sequences.Sequence((kotlin.sequences.map.T)),%20kotlin.Function1((kotlin.sequences.map.T,%20kotlin.sequences.map.R)))/transform) function to each element in the original sequence. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3) println(numbers.map { it * it }) // [1, 4, 9] //sampleEnd } ``` kotlin sorted sorted ====== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <sorted> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> Sequence<T>.sorted(): Sequence<T> ``` Returns a sequence that yields elements of this sequence sorted according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. The operation is *intermediate* and *stateful*. kotlin reduceIndexed reduceIndexed ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [reduceIndexed](reduce-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> Sequence<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` Accumulates value starting with the first element and applying [operation](reduce-indexed#kotlin.sequences%24reduceIndexed(kotlin.sequences.Sequence((kotlin.sequences.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.reduceIndexed.S,%20kotlin.sequences.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. Throws an exception if this sequence is empty. If the sequence can be empty in an expected way, please use [reduceIndexedOrNull](reduce-indexed-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduce { acc, string -> acc + string }) // abcd println(strings.reduceIndexed { index, acc, string -> acc + string + index }) // ab1c2d3 // emptyList<Int>().reduce { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. The operation is *terminal*. kotlin plusElement plusElement =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [plusElement](plus-element) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.plusElement(element: T): Sequence<T> ``` Returns a sequence containing all elements of the original sequence and then the given [element](plus-element#kotlin.sequences%24plusElement(kotlin.sequences.Sequence((kotlin.sequences.plusElement.T)),%20kotlin.sequences.plusElement.T)/element). The operation is *intermediate* and *stateless*. kotlin sumByDouble sumByDouble =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [sumByDouble](sum-by-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") inline fun <T> Sequence<T>.sumByDouble(     selector: (T) -> Double ): Double ``` **Deprecated:** Use sumOf instead. Returns the sum of all values produced by [selector](sum-by-double#kotlin.sequences%24sumByDouble(kotlin.sequences.Sequence((kotlin.sequences.sumByDouble.T)),%20kotlin.Function1((kotlin.sequences.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. The operation is *terminal*. kotlin sequence sequence ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <sequence> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> sequence(     block: suspend SequenceScope<T>.() -> Unit ): Sequence<T> ``` Builds a [Sequence](-sequence/index) lazily yielding values one by one. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = sequence { val start = 0 // yielding a single value yield(start) // yielding an iterable yieldAll(1..5 step 2) // yielding an infinite sequence yieldAll(generateSequence(8) { it * 3 }) } println(sequence.take(7).toList()) // [0, 1, 3, 5, 8, 24, 72] //sampleEnd } ``` ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun fibonacci() = sequence { var terms = Pair(0, 1) // this sequence is infinite while (true) { yield(terms.first) terms = Pair(terms.second, terms.first + terms.second) } } println(fibonacci().take(10).toList()) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] //sampleEnd } ``` **See Also** [kotlin.sequences.generateSequence](generate-sequence) kotlin toList toList ====== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [toList](to-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.toList(): List<T> ``` Returns a [List](../kotlin.collections/-list/index#kotlin.collections.List) containing all elements. The operation is *terminal*. kotlin toMutableList toMutableList ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [toMutableList](to-mutable-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.toMutableList(): MutableList<T> ``` Returns a new [MutableList](../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this sequence. The operation is *terminal*. kotlin forEach forEach ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [forEach](for-each) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.forEach(action: (T) -> Unit) ``` Performs the given [action](for-each#kotlin.sequences%24forEach(kotlin.sequences.Sequence((kotlin.sequences.forEach.T)),%20kotlin.Function1((kotlin.sequences.forEach.T,%20kotlin.Unit)))/action) on each element. The operation is *terminal*. kotlin drop drop ==== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <drop> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.drop(n: Int): Sequence<T> ``` Returns a sequence containing all elements except first [n](drop#kotlin.sequences%24drop(kotlin.sequences.Sequence((kotlin.sequences.drop.T)),%20kotlin.Int)/n) elements. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.drop(23)) // [x, y, z] println(chars.dropLast(23)) // [a, b, c] println(chars.dropWhile { it < 'x' }) // [x, y, z] println(chars.dropLastWhile { it > 'c' }) // [a, b, c] //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](drop#kotlin.sequences%24drop(kotlin.sequences.Sequence((kotlin.sequences.drop.T)),%20kotlin.Int)/n) is negative. kotlin take take ==== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <take> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.take(n: Int): Sequence<T> ``` Returns a sequence containing first [n](take#kotlin.sequences%24take(kotlin.sequences.Sequence((kotlin.sequences.take.T)),%20kotlin.Int)/n) elements. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.take(3)) // [a, b, c] println(chars.takeWhile { it < 'f' }) // [a, b, c, d, e] println(chars.takeLast(2)) // [y, z] println(chars.takeLastWhile { it > 'w' }) // [x, y, z] //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](take#kotlin.sequences%24take(kotlin.sequences.Sequence((kotlin.sequences.take.T)),%20kotlin.Int)/n) is negative. kotlin last last ==== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.last(): T ``` Returns the last element. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the sequence is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T ``` Returns the last element matching the given [predicate](last#kotlin.sequences%24last(kotlin.sequences.Sequence((kotlin.sequences.last.T)),%20kotlin.Function1((kotlin.sequences.last.T,%20kotlin.Boolean)))/predicate). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if no such element is found. kotlin maxOfWithOrNull maxOfWithOrNull =============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxOfWithOrNull](max-of-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Sequence<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.sequences%24maxOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.maxOfWithOrNull.T,%20kotlin.sequences.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.sequences%24maxOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.maxOfWithOrNull.T,%20kotlin.sequences.maxOfWithOrNull.R)))/selector) function applied to each element in the sequence or `null` if there are no elements. The operation is *terminal*. kotlin distinctBy distinctBy ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [distinctBy](distinct-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, K> Sequence<T>.distinctBy(     selector: (T) -> K ): Sequence<T> ``` Returns a sequence containing only elements from the given sequence having distinct keys returned by the given [selector](distinct-by#kotlin.sequences%24distinctBy(kotlin.sequences.Sequence((kotlin.sequences.distinctBy.T)),%20kotlin.Function1((kotlin.sequences.distinctBy.T,%20kotlin.sequences.distinctBy.K)))/selector) function. Among elements of the given sequence with equal keys, only the first one will be present in the resulting sequence. The elements in the resulting sequence are in the same order as they were in the source sequence. The operation is *intermediate* and *stateful*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'A', 'b', 'B', 'A', 'a') println(list.distinct()) // [a, A, b, B] println(list.distinctBy { it.uppercaseChar() }) // [a, b] //sampleEnd } ``` kotlin Package kotlin.sequences Package kotlin.sequences ======================== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) [Sequence](-sequence/index) type that represents lazily evaluated collections. Top-level functions for instantiating sequences and extension functions for sequences. Classification of sequences --------------------------- The sequence operations can be classified into the following groups regarding their state requirements: * *stateless* – operations which require no state and process each element independently like [kotlin.sequences.Sequence.map](map), [kotlin.sequences.Sequence.filter](filter), or require a small constant amount of state to process an element, for example [kotlin.sequences.Sequence.take](take) or [kotlin.sequences.Sequence.drop](drop); * *stateful* – operations which require a significant amount of state, usually proportional to the number of elements in a sequence. If the sequence operation returns another sequence, which is produced lazily, it's called *intermediate*, and otherwise the operation is *terminal*. Examples of terminal operations are [kotlin.sequences.Sequence.toList](to-list), kotlin.sequences.Sequence.max. Sequences can be iterated multiple times, however some sequence implementations might constrain themselves to be iterated only once. That is mentioned specifically in their documentation (e.g. [kotlin.sequences.generateSequence](generate-sequence) overload). The latter sequences throw an exception on an attempt to iterate them the second time. Sequence type that represents lazily evaluated collections. Top-level functions for instantiating sequences and extension functions for sequences. Classification of sequences --------------------------- The sequence operations can be classified into the following groups regarding their state requirements: * *stateless* – operations which require no state and process each element independently like kotlin.sequences.Sequence.map, kotlin.sequences.Sequence.filter, or require a small constant amount of state to process an element, for example kotlin.sequences.Sequence.take or kotlin.sequences.Sequence.drop; * *stateful* – operations which require a significant amount of state, usually proportional to the number of elements in a sequence. If the sequence operation returns another sequence, which is produced lazily, it's called *intermediate*, and otherwise the operation is *terminal*. Examples of terminal operations are kotlin.sequences.Sequence.toList, kotlin.sequences.Sequence.max. Sequences can be iterated multiple times, however some sequence implementations might constrain themselves to be iterated only once. That is mentioned specifically in their documentation (e.g. kotlin.sequences.generateSequence overload). The latter sequences throw an exception on an attempt to iterate them the second time. ### Types **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Sequence](-sequence/index) A sequence that returns values through its iterator. The values are evaluated lazily, and the sequence is potentially infinite. ``` interface Sequence<out T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [SequenceScope](-sequence-scope/index) The scope for yielding values of a [Sequence](-sequence/index) or an [Iterator](../kotlin.collections/-iterator/index#kotlin.collections.Iterator), provides [yield](-sequence-scope/yield) and [yieldAll](-sequence-scope/yield-all) suspension functions. ``` abstract class SequenceScope<in T> ``` ### Extensions for External Classes **Platform and version requirements:** JVM (1.0) #### [java.util.Enumeration](java.util.-enumeration/index) ### Functions **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <all> Returns `true` if all elements match the given [predicate](all#kotlin.sequences%24all(kotlin.sequences.Sequence((kotlin.sequences.all.T)),%20kotlin.Function1((kotlin.sequences.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <any> Returns `true` if sequence has at least one element. ``` fun <T> Sequence<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](any#kotlin.sequences%24any(kotlin.sequences.Sequence((kotlin.sequences.any.T)),%20kotlin.Function1((kotlin.sequences.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](as-iterable) Creates an [Iterable](../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original sequence returning its elements when being iterated. ``` fun <T> Sequence<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](as-sequence) Returns this sequence as a [Sequence](-sequence/index). ``` fun <T> Sequence<T>.asSequence(): Sequence<T> ``` Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <associate> Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](associate#kotlin.sequences%24associate(kotlin.sequences.Sequence((kotlin.sequences.associate.T)),%20kotlin.Function1((kotlin.sequences.associate.T,%20kotlin.Pair((kotlin.sequences.associate.K,%20kotlin.sequences.associate.V)))))/transform) function applied to elements of the given sequence. ``` fun <T, K, V> Sequence<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](associate-by) Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing the elements from the given sequence indexed by the key returned from [keySelector](associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Sequence<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.V)))/valueTransform) and indexed by [keySelector](associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.V)))/keySelector) functions applied to elements of the given sequence. ``` fun <T, K, V> Sequence<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](associate-by-to) Populates and returns the [destination](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)))/keySelector) function applied to each element of the given sequence and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Sequence<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/valueTransform) function applied to elements of the given sequence. ``` fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](associate-to) Populates and returns the [destination](associate-to#kotlin.sequences%24associateTo(kotlin.sequences.Sequence((kotlin.sequences.associateTo.T)),%20kotlin.sequences.associateTo.M,%20kotlin.Function1((kotlin.sequences.associateTo.T,%20kotlin.Pair((kotlin.sequences.associateTo.K,%20kotlin.sequences.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](associate-to#kotlin.sequences%24associateTo(kotlin.sequences.Sequence((kotlin.sequences.associateTo.T)),%20kotlin.sequences.associateTo.M,%20kotlin.Function1((kotlin.sequences.associateTo.T,%20kotlin.Pair((kotlin.sequences.associateTo.K,%20kotlin.sequences.associateTo.V)))))/transform) function applied to each element of the given sequence. ``` fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](associate-with) Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) where keys are elements from the given sequence and values are produced by the [valueSelector](associate-with#kotlin.sequences%24associateWith(kotlin.sequences.Sequence((kotlin.sequences.associateWith.K)),%20kotlin.Function1((kotlin.sequences.associateWith.K,%20kotlin.sequences.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Sequence<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](associate-with-to) Populates and returns the [destination](associate-with-to#kotlin.sequences%24associateWithTo(kotlin.sequences.Sequence((kotlin.sequences.associateWithTo.K)),%20kotlin.sequences.associateWithTo.M,%20kotlin.Function1((kotlin.sequences.associateWithTo.K,%20kotlin.sequences.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given sequence, where key is the element itself and value is provided by the [valueSelector](associate-with-to#kotlin.sequences%24associateWithTo(kotlin.sequences.Sequence((kotlin.sequences.associateWithTo.K)),%20kotlin.sequences.associateWithTo.M,%20kotlin.Function1((kotlin.sequences.associateWithTo.K,%20kotlin.sequences.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Sequence<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <average> Returns an average value of elements in the sequence. ``` fun Sequence<Byte>.average(): Double ``` ``` fun Sequence<Short>.average(): Double ``` ``` fun Sequence<Int>.average(): Double ``` ``` fun Sequence<Long>.average(): Double ``` ``` fun Sequence<Float>.average(): Double ``` ``` fun Sequence<Double>.average(): Double ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <chunked> Splits this sequence into a sequence of lists each not exceeding the given [size](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> ``` Splits this sequence into several lists each not exceeding the given [size](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/size) and applies the given [transform](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/transform) function to an each. ``` fun <T, R> Sequence<T>.chunked(     size: Int,     transform: (List<T>) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [constrainOnce](constrain-once) Returns a wrapper sequence that provides values of this sequence, but ensures it can be iterated only one time. ``` fun <T> Sequence<T>.constrainOnce(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Returns `true` if [element](contains#kotlin.sequences%24contains(kotlin.sequences.Sequence((kotlin.sequences.contains.T)),%20kotlin.sequences.contains.T)/element) is found in the sequence. ``` operator fun <T> Sequence<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <count> Returns the number of elements in this sequence. ``` fun <T> Sequence<T>.count(): Int ``` Returns the number of elements matching the given [predicate](count#kotlin.sequences%24count(kotlin.sequences.Sequence((kotlin.sequences.count.T)),%20kotlin.Function1((kotlin.sequences.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <distinct> Returns a sequence containing only distinct elements from the given sequence. ``` fun <T> Sequence<T>.distinct(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](distinct-by) Returns a sequence containing only elements from the given sequence having distinct keys returned by the given [selector](distinct-by#kotlin.sequences%24distinctBy(kotlin.sequences.Sequence((kotlin.sequences.distinctBy.T)),%20kotlin.Function1((kotlin.sequences.distinctBy.T,%20kotlin.sequences.distinctBy.K)))/selector) function. ``` fun <T, K> Sequence<T>.distinctBy(     selector: (T) -> K ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <drop> Returns a sequence containing all elements except first [n](drop#kotlin.sequences%24drop(kotlin.sequences.Sequence((kotlin.sequences.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Sequence<T>.drop(n: Int): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](drop-while) Returns a sequence containing all elements except first elements that satisfy the given [predicate](drop-while#kotlin.sequences%24dropWhile(kotlin.sequences.Sequence((kotlin.sequences.dropWhile.T)),%20kotlin.Function1((kotlin.sequences.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.dropWhile(     predicate: (T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](element-at) Returns an element at the given [index](element-at#kotlin.sequences%24elementAt(kotlin.sequences.Sequence((kotlin.sequences.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.sequences%24elementAt(kotlin.sequences.Sequence((kotlin.sequences.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this sequence. ``` fun <T> Sequence<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](element-at-or-else) Returns an element at the given [index](element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/defaultValue) function if the [index](element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/index) is out of bounds of this sequence. ``` fun <T> Sequence<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](element-at-or-null) Returns an element at the given [index](element-at-or-null#kotlin.sequences%24elementAtOrNull(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.sequences%24elementAtOrNull(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this sequence. ``` fun <T> Sequence<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [emptySequence](empty-sequence) Returns an empty sequence. ``` fun <T> emptySequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <filter> Returns a sequence containing only elements matching the given [predicate](filter#kotlin.sequences%24filter(kotlin.sequences.Sequence((kotlin.sequences.filter.T)),%20kotlin.Function1((kotlin.sequences.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.filter(     predicate: (T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](filter-indexed) Returns a sequence containing only elements matching the given [predicate](filter-indexed#kotlin.sequences%24filterIndexed(kotlin.sequences.Sequence((kotlin.sequences.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](filter-indexed-to) Appends all elements matching the given [predicate](filter-indexed-to#kotlin.sequences%24filterIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.filterIndexedTo.T)),%20kotlin.sequences.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-indexed-to#kotlin.sequences%24filterIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.filterIndexedTo.T)),%20kotlin.sequences.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a sequence containing all elements that are instances of specified type parameter R. ``` fun <R> Sequence<*>.filterIsInstance(): Sequence<R> ``` **Platform and version requirements:** JVM (1.0) Returns a sequence containing all elements that are instances of specified class. ``` fun <R> Sequence<*>.filterIsInstance(     klass: Class<R> ): Sequence<R> ``` #### [filterIsInstanceTo](filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](filter-is-instance-to#kotlin.sequences%24filterIsInstanceTo(kotlin.sequences.Sequence((kotlin.Any?)),%20kotlin.sequences.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Sequence<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](filter-is-instance-to#kotlin.sequences%24filterIsInstanceTo(kotlin.sequences.Sequence((kotlin.Any?)),%20kotlin.sequences.filterIsInstanceTo.C,%20java.lang.Class((kotlin.sequences.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Sequence<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](filter-not) Returns a sequence containing all elements not matching the given [predicate](filter-not#kotlin.sequences%24filterNot(kotlin.sequences.Sequence((kotlin.sequences.filterNot.T)),%20kotlin.Function1((kotlin.sequences.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.filterNot(     predicate: (T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](filter-not-null) Returns a sequence containing all elements that are not `null`. ``` fun <T : Any> Sequence<T?>.filterNotNull(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](filter-not-null-to) Appends all elements that are not `null` to the given [destination](filter-not-null-to#kotlin.sequences%24filterNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotNullTo.T?)),%20kotlin.sequences.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Sequence<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](filter-not-to) Appends all elements not matching the given [predicate](filter-not-to#kotlin.sequences%24filterNotTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotTo.T)),%20kotlin.sequences.filterNotTo.C,%20kotlin.Function1((kotlin.sequences.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-not-to#kotlin.sequences%24filterNotTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotTo.T)),%20kotlin.sequences.filterNotTo.C,%20kotlin.Function1((kotlin.sequences.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Sequence<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](filter-to) Appends all elements matching the given [predicate](filter-to#kotlin.sequences%24filterTo(kotlin.sequences.Sequence((kotlin.sequences.filterTo.T)),%20kotlin.sequences.filterTo.C,%20kotlin.Function1((kotlin.sequences.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-to#kotlin.sequences%24filterTo(kotlin.sequences.Sequence((kotlin.sequences.filterTo.T)),%20kotlin.sequences.filterTo.C,%20kotlin.Function1((kotlin.sequences.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Sequence<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <find> Returns the first element matching the given [predicate](find#kotlin.sequences%24find(kotlin.sequences.Sequence((kotlin.sequences.find.T)),%20kotlin.Function1((kotlin.sequences.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Sequence<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](find-last) Returns the last element matching the given [predicate](find-last#kotlin.sequences%24findLast(kotlin.sequences.Sequence((kotlin.sequences.findLast.T)),%20kotlin.Function1((kotlin.sequences.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Sequence<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> Returns the first element. ``` fun <T> Sequence<T>.first(): T ``` Returns the first element matching the given [predicate](first#kotlin.sequences%24first(kotlin.sequences.Sequence((kotlin.sequences.first.T)),%20kotlin.Function1((kotlin.sequences.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](first-not-null-of) Returns the first non-null value produced by [transform](first-not-null-of#kotlin.sequences%24firstNotNullOf(kotlin.sequences.Sequence((kotlin.sequences.firstNotNullOf.T)),%20kotlin.Function1((kotlin.sequences.firstNotNullOf.T,%20kotlin.sequences.firstNotNullOf.R?)))/transform) function being applied to elements of this sequence in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Sequence<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](first-not-null-of-or-null) Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.sequences%24firstNotNullOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.firstNotNullOfOrNull.T,%20kotlin.sequences.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this sequence in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Sequence<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](first-or-null) Returns the first element, or `null` if the sequence is empty. ``` fun <T> Sequence<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](first-or-null#kotlin.sequences%24firstOrNull(kotlin.sequences.Sequence((kotlin.sequences.firstOrNull.T)),%20kotlin.Function1((kotlin.sequences.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Sequence<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](flat-map) Returns a single sequence of all elements from results of [transform](flat-map#kotlin.sequences%24flatMap(kotlin.sequences.Sequence((kotlin.sequences.flatMap.T)),%20kotlin.Function1((kotlin.sequences.flatMap.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMap.R)))))/transform) function being invoked on each element of original sequence. ``` fun <T, R> Sequence<T>.flatMap(     transform: (T) -> Iterable<R> ): Sequence<R> ``` ``` fun <T, R> Sequence<T>.flatMap(     transform: (T) -> Sequence<R> ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](flat-map-indexed) Returns a single sequence of all elements yielded from results of [transform](flat-map-indexed#kotlin.sequences%24flatMapIndexed(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original sequence. ``` fun <T, R> Sequence<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): Sequence<R> ``` ``` fun <T, R> Sequence<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](flat-map-indexed-to) Appends all elements yielded from results of [transform](flat-map-indexed-to#kotlin.sequences%24flatMapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexedTo.T)),%20kotlin.sequences.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original sequence, to the given [destination](flat-map-indexed-to#kotlin.sequences%24flatMapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexedTo.T)),%20kotlin.sequences.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](flat-map-to) Appends all elements yielded from results of [transform](flat-map-to#kotlin.sequences%24flatMapTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapTo.T)),%20kotlin.sequences.flatMapTo.C,%20kotlin.Function1((kotlin.sequences.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapTo.R)))))/transform) function being invoked on each element of original sequence, to the given [destination](flat-map-to#kotlin.sequences%24flatMapTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapTo.T)),%20kotlin.sequences.flatMapTo.C,%20kotlin.Function1((kotlin.sequences.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <flatten> Returns a sequence of all elements from all sequences in this sequence. ``` fun <T> Sequence<Sequence<T>>.flatten(): Sequence<T> ``` Returns a sequence of all elements from all iterables in this sequence. ``` fun <T> Sequence<Iterable<T>>.flatten(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <fold> Accumulates value starting with [initial](fold#kotlin.sequences%24fold(kotlin.sequences.Sequence((kotlin.sequences.fold.T)),%20kotlin.sequences.fold.R,%20kotlin.Function2((kotlin.sequences.fold.R,%20kotlin.sequences.fold.T,%20)))/initial) value and applying [operation](fold#kotlin.sequences%24fold(kotlin.sequences.Sequence((kotlin.sequences.fold.T)),%20kotlin.sequences.fold.R,%20kotlin.Function2((kotlin.sequences.fold.R,%20kotlin.sequences.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Sequence<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](fold-indexed) Accumulates value starting with [initial](fold-indexed#kotlin.sequences%24foldIndexed(kotlin.sequences.Sequence((kotlin.sequences.foldIndexed.T)),%20kotlin.sequences.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.foldIndexed.R,%20kotlin.sequences.foldIndexed.T,%20)))/initial) value and applying [operation](fold-indexed#kotlin.sequences%24foldIndexed(kotlin.sequences.Sequence((kotlin.sequences.foldIndexed.T)),%20kotlin.sequences.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.foldIndexed.R,%20kotlin.sequences.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. ``` fun <T, R> Sequence<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](for-each) Performs the given [action](for-each#kotlin.sequences%24forEach(kotlin.sequences.Sequence((kotlin.sequences.forEach.T)),%20kotlin.Function1((kotlin.sequences.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Sequence<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](for-each-indexed) Performs the given [action](for-each-indexed#kotlin.sequences%24forEachIndexed(kotlin.sequences.Sequence((kotlin.sequences.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Sequence<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [generateSequence](generate-sequence) Returns a sequence which invokes the function to calculate the next value on each iteration until the function returns `null`. ``` fun <T : Any> generateSequence(     nextFunction: () -> T? ): Sequence<T> ``` Returns a sequence defined by the starting value [seed](generate-sequence#kotlin.sequences%24generateSequence(kotlin.sequences.generateSequence.T?,%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/seed) and the function [nextFunction](generate-sequence#kotlin.sequences%24generateSequence(kotlin.sequences.generateSequence.T?,%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/nextFunction), which is invoked to calculate the next value based on the previous one on each iteration. ``` fun <T : Any> generateSequence(     seed: T?,     nextFunction: (T) -> T? ): Sequence<T> ``` Returns a sequence defined by the function [seedFunction](generate-sequence#kotlin.sequences%24generateSequence(kotlin.Function0((kotlin.sequences.generateSequence.T?)),%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/seedFunction), which is invoked to produce the starting value, and the [nextFunction](generate-sequence#kotlin.sequences%24generateSequence(kotlin.Function0((kotlin.sequences.generateSequence.T?)),%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/nextFunction), which is invoked to calculate the next value based on the previous one on each iteration. ``` fun <T : Any> generateSequence(     seedFunction: () -> T?,     nextFunction: (T) -> T? ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](group-by) Groups elements of the original sequence by the key returned by the given [keySelector](group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Sequence<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.V)))/valueTransform) function applied to each element of the original sequence by the key returned by the given [keySelector](group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Sequence<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](group-by-to) Groups elements of the original sequence by the key returned by the given [keySelector](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Sequence<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/valueTransform) function applied to each element of the original sequence by the key returned by the given [keySelector](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Sequence<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](grouping-by) Creates a [Grouping](../kotlin.collections/-grouping/index) source from a sequence to be used later with one of group-and-fold operations using the specified [keySelector](grouping-by#kotlin.sequences%24groupingBy(kotlin.sequences.Sequence((kotlin.sequences.groupingBy.T)),%20kotlin.Function1((kotlin.sequences.groupingBy.T,%20kotlin.sequences.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Sequence<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](if-empty) Returns a sequence that iterates through the elements either of this sequence or, if this sequence turns out to be empty, of the sequence returned by [defaultValue](if-empty#kotlin.sequences%24ifEmpty(kotlin.sequences.Sequence((kotlin.sequences.ifEmpty.T)),%20kotlin.Function0((kotlin.sequences.Sequence((kotlin.sequences.ifEmpty.T)))))/defaultValue) function. ``` fun <T> Sequence<T>.ifEmpty(     defaultValue: () -> Sequence<T> ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](index-of) Returns first index of [element](index-of#kotlin.sequences%24indexOf(kotlin.sequences.Sequence((kotlin.sequences.indexOf.T)),%20kotlin.sequences.indexOf.T)/element), or -1 if the sequence does not contain element. ``` fun <T> Sequence<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](index-of-first) Returns index of the first element matching the given [predicate](index-of-first#kotlin.sequences%24indexOfFirst(kotlin.sequences.Sequence((kotlin.sequences.indexOfFirst.T)),%20kotlin.Function1((kotlin.sequences.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the sequence does not contain such element. ``` fun <T> Sequence<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](index-of-last) Returns index of the last element matching the given [predicate](index-of-last#kotlin.sequences%24indexOfLast(kotlin.sequences.Sequence((kotlin.sequences.indexOfLast.T)),%20kotlin.Function1((kotlin.sequences.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the sequence does not contain such element. ``` fun <T> Sequence<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <iterator> Builds an [Iterator](../kotlin.collections/-iterator/index#kotlin.collections.Iterator) lazily yielding values one by one. ``` fun <T> iterator(     block: suspend SequenceScope<T>.() -> Unit ): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](join-to) Appends the string from all the elements separated using [separator](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Sequence<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](join-to-string) Creates a string from all the elements separated using [separator](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Sequence<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> Returns the last element. ``` fun <T> Sequence<T>.last(): T ``` Returns the last element matching the given [predicate](last#kotlin.sequences%24last(kotlin.sequences.Sequence((kotlin.sequences.last.T)),%20kotlin.Function1((kotlin.sequences.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](last-index-of) Returns last index of [element](last-index-of#kotlin.sequences%24lastIndexOf(kotlin.sequences.Sequence((kotlin.sequences.lastIndexOf.T)),%20kotlin.sequences.lastIndexOf.T)/element), or -1 if the sequence does not contain element. ``` fun <T> Sequence<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](last-or-null) Returns the last element, or `null` if the sequence is empty. ``` fun <T> Sequence<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](last-or-null#kotlin.sequences%24lastOrNull(kotlin.sequences.Sequence((kotlin.sequences.lastOrNull.T)),%20kotlin.Function1((kotlin.sequences.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Sequence<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <map> Returns a sequence containing the results of applying the given [transform](map#kotlin.sequences%24map(kotlin.sequences.Sequence((kotlin.sequences.map.T)),%20kotlin.Function1((kotlin.sequences.map.T,%20kotlin.sequences.map.R)))/transform) function to each element in the original sequence. ``` fun <T, R> Sequence<T>.map(transform: (T) -> R): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](map-indexed) Returns a sequence containing the results of applying the given [transform](map-indexed#kotlin.sequences%24mapIndexed(kotlin.sequences.Sequence((kotlin.sequences.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexed.T,%20kotlin.sequences.mapIndexed.R)))/transform) function to each element and its index in the original sequence. ``` fun <T, R> Sequence<T>.mapIndexed(     transform: (index: Int, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](map-indexed-not-null) Returns a sequence containing only the non-null results of applying the given [transform](map-indexed-not-null#kotlin.sequences%24mapIndexedNotNull(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNull.T,%20kotlin.sequences.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original sequence. ``` fun <T, R : Any> Sequence<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](map-indexed-not-null-to) Applies the given [transform](map-indexed-not-null-to#kotlin.sequences%24mapIndexedNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNullTo.T)),%20kotlin.sequences.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNullTo.T,%20kotlin.sequences.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original sequence and appends only the non-null results to the given [destination](map-indexed-not-null-to#kotlin.sequences%24mapIndexedNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNullTo.T)),%20kotlin.sequences.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNullTo.T,%20kotlin.sequences.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](map-indexed-to) Applies the given [transform](map-indexed-to#kotlin.sequences%24mapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedTo.T)),%20kotlin.sequences.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedTo.T,%20kotlin.sequences.mapIndexedTo.R)))/transform) function to each element and its index in the original sequence and appends the results to the given [destination](map-indexed-to#kotlin.sequences%24mapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedTo.T)),%20kotlin.sequences.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedTo.T,%20kotlin.sequences.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](map-not-null) Returns a sequence containing only the non-null results of applying the given [transform](map-not-null#kotlin.sequences%24mapNotNull(kotlin.sequences.Sequence((kotlin.sequences.mapNotNull.T)),%20kotlin.Function1((kotlin.sequences.mapNotNull.T,%20kotlin.sequences.mapNotNull.R?)))/transform) function to each element in the original sequence. ``` fun <T, R : Any> Sequence<T>.mapNotNull(     transform: (T) -> R? ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](map-not-null-to) Applies the given [transform](map-not-null-to#kotlin.sequences%24mapNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapNotNullTo.T)),%20kotlin.sequences.mapNotNullTo.C,%20kotlin.Function1((kotlin.sequences.mapNotNullTo.T,%20kotlin.sequences.mapNotNullTo.R?)))/transform) function to each element in the original sequence and appends only the non-null results to the given [destination](map-not-null-to#kotlin.sequences%24mapNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapNotNullTo.T)),%20kotlin.sequences.mapNotNullTo.C,%20kotlin.Function1((kotlin.sequences.mapNotNullTo.T,%20kotlin.sequences.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](map-to) Applies the given [transform](map-to#kotlin.sequences%24mapTo(kotlin.sequences.Sequence((kotlin.sequences.mapTo.T)),%20kotlin.sequences.mapTo.C,%20kotlin.Function1((kotlin.sequences.mapTo.T,%20kotlin.sequences.mapTo.R)))/transform) function to each element of the original sequence and appends the results to the given [destination](map-to#kotlin.sequences%24mapTo(kotlin.sequences.Sequence((kotlin.sequences.mapTo.T)),%20kotlin.sequences.mapTo.C,%20kotlin.Function1((kotlin.sequences.mapTo.T,%20kotlin.sequences.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` #### <max> Returns the largest element. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Sequence<Double>.max(): Double ``` **Platform and version requirements:** JVM (1.1) ``` fun Sequence<Double>.max(): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Sequence<Float>.max(): Float ``` **Platform and version requirements:** JVM (1.1) ``` fun Sequence<Float>.max(): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T : Comparable<T>> Sequence<T>.max(): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T : Comparable<T>> Sequence<T>.max(): T? ``` #### [maxBy](max-by) Returns the first element yielding the largest value of the given function. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T, R : Comparable<R>> Sequence<T>.maxBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T, R : Comparable<R>> Sequence<T>.maxBy(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Sequence<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](max-of) Returns the largest value among all values produced by [selector](max-of#kotlin.sequences%24maxOf(kotlin.sequences.Sequence((kotlin.sequences.maxOf.T)),%20kotlin.Function1((kotlin.sequences.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. ``` fun <T> Sequence<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Sequence<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Sequence<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](max-of-or-null) Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.sequences%24maxOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the sequence or `null` if there are no elements. ``` fun <T> Sequence<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Sequence<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Sequence<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](max-of-with) Returns the largest value according to the provided [comparator](max-of-with#kotlin.sequences%24maxOfWith(kotlin.sequences.Sequence((kotlin.sequences.maxOfWith.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWith.R)),%20kotlin.Function1((kotlin.sequences.maxOfWith.T,%20kotlin.sequences.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.sequences%24maxOfWith(kotlin.sequences.Sequence((kotlin.sequences.maxOfWith.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWith.R)),%20kotlin.Function1((kotlin.sequences.maxOfWith.T,%20kotlin.sequences.maxOfWith.R)))/selector) function applied to each element in the sequence. ``` fun <T, R> Sequence<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](max-of-with-or-null) Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.sequences%24maxOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.maxOfWithOrNull.T,%20kotlin.sequences.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.sequences%24maxOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.maxOfWithOrNull.T,%20kotlin.sequences.maxOfWithOrNull.R)))/selector) function applied to each element in the sequence or `null` if there are no elements. ``` fun <T, R> Sequence<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOrNull](max-or-null) Returns the largest element or `null` if there are no elements. ``` fun Sequence<Double>.maxOrNull(): Double? ``` ``` fun Sequence<Float>.maxOrNull(): Float? ``` ``` fun <T : Comparable<T>> Sequence<T>.maxOrNull(): T? ``` #### [maxWith](max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](max-with#kotlin.sequences%24maxWith(kotlin.sequences.Sequence((kotlin.sequences.maxWith.T)),%20kotlin.Comparator((kotlin.sequences.maxWith.T)))/comparator). ``` fun <T> Sequence<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Sequence<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](max-with-or-null) Returns the first element having the largest value according to the provided [comparator](max-with-or-null#kotlin.sequences%24maxWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Sequence<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` #### <min> Returns the smallest element. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Sequence<Double>.min(): Double ``` **Platform and version requirements:** JVM (1.1) ``` fun Sequence<Double>.min(): Double? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun Sequence<Float>.min(): Float ``` **Platform and version requirements:** JVM (1.1) ``` fun Sequence<Float>.min(): Float? ``` **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T : Comparable<T>> Sequence<T>.min(): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T : Comparable<T>> Sequence<T>.min(): T? ``` #### [minBy](min-by) Returns the first element yielding the smallest value of the given function. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun <T, R : Comparable<R>> Sequence<T>.minBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T, R : Comparable<R>> Sequence<T>.minBy(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Sequence<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](min-of) Returns the smallest value among all values produced by [selector](min-of#kotlin.sequences%24minOf(kotlin.sequences.Sequence((kotlin.sequences.minOf.T)),%20kotlin.Function1((kotlin.sequences.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. ``` fun <T> Sequence<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Sequence<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Sequence<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](min-of-or-null) Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.sequences%24minOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the sequence or `null` if there are no elements. ``` fun <T> Sequence<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Sequence<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Sequence<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](min-of-with) Returns the smallest value according to the provided [comparator](min-of-with#kotlin.sequences%24minOfWith(kotlin.sequences.Sequence((kotlin.sequences.minOfWith.T)),%20kotlin.Comparator((kotlin.sequences.minOfWith.R)),%20kotlin.Function1((kotlin.sequences.minOfWith.T,%20kotlin.sequences.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.sequences%24minOfWith(kotlin.sequences.Sequence((kotlin.sequences.minOfWith.T)),%20kotlin.Comparator((kotlin.sequences.minOfWith.R)),%20kotlin.Function1((kotlin.sequences.minOfWith.T,%20kotlin.sequences.minOfWith.R)))/selector) function applied to each element in the sequence. ``` fun <T, R> Sequence<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](min-of-with-or-null) Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.sequences%24minOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.minOfWithOrNull.T,%20kotlin.sequences.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.sequences%24minOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.minOfWithOrNull.T,%20kotlin.sequences.minOfWithOrNull.R)))/selector) function applied to each element in the sequence or `null` if there are no elements. ``` fun <T, R> Sequence<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOrNull](min-or-null) Returns the smallest element or `null` if there are no elements. ``` fun Sequence<Double>.minOrNull(): Double? ``` ``` fun Sequence<Float>.minOrNull(): Float? ``` ``` fun <T : Comparable<T>> Sequence<T>.minOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <minus> Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.sequences.minus.T)/element). ``` operator fun <T> Sequence<T>.minus(element: T): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.Array((kotlin.sequences.minus.T)))/elements) array. ``` operator fun <T> Sequence<T>.minus(     elements: Array<out T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.collections.Iterable((kotlin.sequences.minus.T)))/elements) collection. ``` operator fun <T> Sequence<T>.minus(     elements: Iterable<T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.sequences.Sequence((kotlin.sequences.minus.T)))/elements) sequence. ``` operator fun <T> Sequence<T>.minus(     elements: Sequence<T> ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](minus-element) Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element](minus-element#kotlin.sequences%24minusElement(kotlin.sequences.Sequence((kotlin.sequences.minusElement.T)),%20kotlin.sequences.minusElement.T)/element). ``` fun <T> Sequence<T>.minusElement(element: T): Sequence<T> ``` #### [minWith](min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](min-with#kotlin.sequences%24minWith(kotlin.sequences.Sequence((kotlin.sequences.minWith.T)),%20kotlin.Comparator((kotlin.sequences.minWith.T)))/comparator). ``` fun <T> Sequence<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Sequence<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](min-with-or-null#kotlin.sequences%24minWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Sequence<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <none> Returns `true` if the sequence has no elements. ``` fun <T> Sequence<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](none#kotlin.sequences%24none(kotlin.sequences.Sequence((kotlin.sequences.none.T)),%20kotlin.Function1((kotlin.sequences.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](on-each) Returns a sequence which performs the given [action](on-each#kotlin.sequences%24onEach(kotlin.sequences.Sequence((kotlin.sequences.onEach.T)),%20kotlin.Function1((kotlin.sequences.onEach.T,%20kotlin.Unit)))/action) on each element of the original sequence as they pass through it. ``` fun <T> Sequence<T>.onEach(action: (T) -> Unit): Sequence<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](on-each-indexed) Returns a sequence which performs the given [action](on-each-indexed#kotlin.sequences%24onEachIndexed(kotlin.sequences.Sequence((kotlin.sequences.onEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.onEachIndexed.T,%20kotlin.Unit)))/action) on each element of the original sequence as they pass through it. ``` fun <T> Sequence<T>.onEachIndexed(     action: (index: Int, T) -> Unit ): Sequence<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [orEmpty](or-empty) Returns this sequence if it's not `null` and the empty sequence otherwise. ``` fun <T> Sequence<T>?.orEmpty(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <partition> Splits the original sequence into pair of lists, where *first* list contains elements for which [predicate](partition#kotlin.sequences%24partition(kotlin.sequences.Sequence((kotlin.sequences.partition.T)),%20kotlin.Function1((kotlin.sequences.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](partition#kotlin.sequences%24partition(kotlin.sequences.Sequence((kotlin.sequences.partition.T)),%20kotlin.Function1((kotlin.sequences.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Sequence<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Returns a sequence containing all elements of the original sequence and then the given [element](plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.sequences.plus.T)/element). ``` operator fun <T> Sequence<T>.plus(element: T): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.Array((kotlin.sequences.plus.T)))/elements) array. ``` operator fun <T> Sequence<T>.plus(     elements: Array<out T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.collections.Iterable((kotlin.sequences.plus.T)))/elements) collection. ``` operator fun <T> Sequence<T>.plus(     elements: Iterable<T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.sequences.Sequence((kotlin.sequences.plus.T)))/elements) sequence. ``` operator fun <T> Sequence<T>.plus(     elements: Sequence<T> ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](plus-element) Returns a sequence containing all elements of the original sequence and then the given [element](plus-element#kotlin.sequences%24plusElement(kotlin.sequences.Sequence((kotlin.sequences.plusElement.T)),%20kotlin.sequences.plusElement.T)/element). ``` fun <T> Sequence<T>.plusElement(element: T): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <reduce> Accumulates value starting with the first element and applying [operation](reduce#kotlin.sequences%24reduce(kotlin.sequences.Sequence((kotlin.sequences.reduce.T)),%20kotlin.Function2((kotlin.sequences.reduce.S,%20kotlin.sequences.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Sequence<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](reduce-indexed) Accumulates value starting with the first element and applying [operation](reduce-indexed#kotlin.sequences%24reduceIndexed(kotlin.sequences.Sequence((kotlin.sequences.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.reduceIndexed.S,%20kotlin.sequences.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. ``` fun <S, T : S> Sequence<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](reduce-indexed-or-null#kotlin.sequences%24reduceIndexedOrNull(kotlin.sequences.Sequence((kotlin.sequences.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.reduceIndexedOrNull.S,%20kotlin.sequences.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. ``` fun <S, T : S> Sequence<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](reduce-or-null) Accumulates value starting with the first element and applying [operation](reduce-or-null#kotlin.sequences%24reduceOrNull(kotlin.sequences.Sequence((kotlin.sequences.reduceOrNull.T)),%20kotlin.Function2((kotlin.sequences.reduceOrNull.S,%20kotlin.sequences.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Sequence<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](running-fold) Returns a sequence containing successive accumulation values generated by applying [operation](running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/initial) value. ``` fun <T, R> Sequence<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](running-fold-indexed) Returns a sequence containing successive accumulation values generated by applying [operation](running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with [initial](running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Sequence<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](running-reduce) Returns a sequence containing successive accumulation values generated by applying [operation](running-reduce#kotlin.sequences%24runningReduce(kotlin.sequences.Sequence((kotlin.sequences.runningReduce.T)),%20kotlin.Function2((kotlin.sequences.runningReduce.S,%20kotlin.sequences.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this sequence. ``` fun <S, T : S> Sequence<T>.runningReduce(     operation: (acc: S, T) -> S ): Sequence<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](running-reduce-indexed) Returns a sequence containing successive accumulation values generated by applying [operation](running-reduce-indexed#kotlin.sequences%24runningReduceIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningReduceIndexed.S,%20kotlin.sequences.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with the first element of this sequence. ``` fun <S, T : S> Sequence<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): Sequence<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### <scan> Returns a sequence containing successive accumulation values generated by applying [operation](scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/initial) value. ``` fun <T, R> Sequence<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](scan-indexed) Returns a sequence containing successive accumulation values generated by applying [operation](scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with [initial](scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Sequence<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <sequence> Builds a [Sequence](-sequence/index) lazily yielding values one by one. ``` fun <T> sequence(     block: suspend SequenceScope<T>.() -> Unit ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Sequence](-sequence) Given an [iterator](-sequence#kotlin.sequences%24Sequence(kotlin.Function0((kotlin.collections.Iterator((kotlin.sequences.Sequence.T)))))/iterator) function constructs a [Sequence](-sequence/index) that returns values through the [Iterator](../kotlin.collections/-iterator/index#kotlin.collections.Iterator) provided by that function. The values are evaluated lazily, and the sequence is potentially infinite. ``` fun <T> Sequence(iterator: () -> Iterator<T>): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sequenceOf](sequence-of) Creates a sequence that returns the specified values. ``` fun <T> sequenceOf(vararg elements: T): Sequence<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### <shuffled> Returns a sequence that yields elements of this sequence randomly shuffled. ``` fun <T> Sequence<T>.shuffled(): Sequence<T> ``` Returns a sequence that yields elements of this sequence randomly shuffled using the specified [random](shuffled#kotlin.sequences%24shuffled(kotlin.sequences.Sequence((kotlin.sequences.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Sequence<T>.shuffled(random: Random): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <single> Returns the single element, or throws an exception if the sequence is empty or has more than one element. ``` fun <T> Sequence<T>.single(): T ``` Returns the single element matching the given [predicate](single#kotlin.sequences%24single(kotlin.sequences.Sequence((kotlin.sequences.single.T)),%20kotlin.Function1((kotlin.sequences.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Sequence<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](single-or-null) Returns single element, or `null` if the sequence is empty or has more than one element. ``` fun <T> Sequence<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](single-or-null#kotlin.sequences%24singleOrNull(kotlin.sequences.Sequence((kotlin.sequences.singleOrNull.T)),%20kotlin.Function1((kotlin.sequences.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Sequence<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <sorted> Returns a sequence that yields elements of this sequence sorted according to their natural sort order. ``` fun <T : Comparable<T>> Sequence<T>.sorted(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](sorted-by) Returns a sequence that yields elements of this sequence sorted according to natural sort order of the value returned by specified [selector](sorted-by#kotlin.sequences%24sortedBy(kotlin.sequences.Sequence((kotlin.sequences.sortedBy.T)),%20kotlin.Function1((kotlin.sequences.sortedBy.T,%20kotlin.sequences.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Sequence<T>.sortedBy(     selector: (T) -> R? ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](sorted-by-descending) Returns a sequence that yields elements of this sequence sorted descending according to natural sort order of the value returned by specified [selector](sorted-by-descending#kotlin.sequences%24sortedByDescending(kotlin.sequences.Sequence((kotlin.sequences.sortedByDescending.T)),%20kotlin.Function1((kotlin.sequences.sortedByDescending.T,%20kotlin.sequences.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Sequence<T>.sortedByDescending(     selector: (T) -> R? ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](sorted-descending) Returns a sequence that yields elements of this sequence sorted descending according to their natural sort order. ``` fun <T : Comparable<T>> Sequence<T>.sortedDescending(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](sorted-with) Returns a sequence that yields elements of this sequence sorted according to the specified [comparator](sorted-with#kotlin.sequences%24sortedWith(kotlin.sequences.Sequence((kotlin.sequences.sortedWith.T)),%20kotlin.Comparator((kotlin.sequences.sortedWith.T)))/comparator). ``` fun <T> Sequence<T>.sortedWith(     comparator: Comparator<in T> ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <sum> Returns the sum of all elements in the sequence. ``` fun Sequence<Byte>.sum(): Int ``` ``` fun Sequence<Short>.sum(): Int ``` ``` fun Sequence<Int>.sum(): Int ``` ``` fun Sequence<Long>.sum(): Long ``` ``` fun Sequence<Float>.sum(): Float ``` ``` fun Sequence<Double>.sum(): Double ``` ``` fun Sequence<UInt>.sum(): UInt ``` ``` fun Sequence<ULong>.sum(): ULong ``` ``` fun Sequence<UByte>.sum(): UInt ``` ``` fun Sequence<UShort>.sum(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](sum-by) Returns the sum of all values produced by [selector](sum-by#kotlin.sequences%24sumBy(kotlin.sequences.Sequence((kotlin.sequences.sumBy.T)),%20kotlin.Function1((kotlin.sequences.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the sequence. ``` fun <T> Sequence<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](sum-by-double) Returns the sum of all values produced by [selector](sum-by-double#kotlin.sequences%24sumByDouble(kotlin.sequences.Sequence((kotlin.sequences.sumByDouble.T)),%20kotlin.Function1((kotlin.sequences.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. ``` fun <T> Sequence<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](sum-of) Returns the sum of all values produced by [selector](sum-of#kotlin.sequences%24sumOf(kotlin.sequences.Sequence((kotlin.sequences.sumOf.T)),%20kotlin.Function1((kotlin.sequences.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Sequence<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Sequence<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <take> Returns a sequence containing first [n](take#kotlin.sequences%24take(kotlin.sequences.Sequence((kotlin.sequences.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Sequence<T>.take(n: Int): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](take-while) Returns a sequence containing first elements satisfying the given [predicate](take-while#kotlin.sequences%24takeWhile(kotlin.sequences.Sequence((kotlin.sequences.takeWhile.T)),%20kotlin.Function1((kotlin.sequences.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.takeWhile(     predicate: (T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](to-collection) Appends all elements to the given [destination](to-collection#kotlin.sequences%24toCollection(kotlin.sequences.Sequence((kotlin.sequences.toCollection.T)),%20kotlin.sequences.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Sequence<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](to-hash-set) Returns a new [HashSet](../kotlin.collections/-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Sequence<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](to-list) Returns a [List](../kotlin.collections/-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Sequence<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](to-mutable-list) Returns a new [MutableList](../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this sequence. ``` fun <T> Sequence<T>.toMutableList(): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](to-mutable-set) Returns a new [MutableSet](../kotlin.collections/-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given sequence. ``` fun <T> Sequence<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](to-set) Returns a [Set](../kotlin.collections/-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Sequence<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T : Comparable<T>> Sequence<T>.toSortedSet(): SortedSet<T> ``` ``` fun <T> Sequence<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <unzip> Returns a pair of lists, where *first* list is built from the first values of each pair from this sequence, *second* list is built from the second values of each pair from this sequence. ``` fun <T, R> Sequence<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <windowed> Returns a sequence of snapshots of the window of the given [size](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this sequence with the given [step](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Sequence<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): Sequence<List<T>> ``` Returns a sequence of results of applying the given [transform](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/size) sliding along this sequence with the given [step](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/step). ``` fun <T, R> Sequence<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](with-index) Returns a sequence that wraps each element of the original sequence into an [IndexedValue](../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Sequence<T>.withIndex(): Sequence<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <zip> Returns a sequence of values built from the elements of `this` sequence and the [other](zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)))/other) sequence with the same index. The resulting sequence ends as soon as the shortest input sequence ends. ``` infix fun <T, R> Sequence<T>.zip(     other: Sequence<R> ): Sequence<Pair<T, R>> ``` Returns a sequence of values built from the elements of `this` sequence and the [other](zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)),%20kotlin.Function2((kotlin.sequences.zip.T,%20kotlin.sequences.zip.R,%20kotlin.sequences.zip.V)))/other) sequence with the same index using the provided [transform](zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)),%20kotlin.Function2((kotlin.sequences.zip.T,%20kotlin.sequences.zip.R,%20kotlin.sequences.zip.V)))/transform) function applied to each pair of elements. The resulting sequence ends as soon as the shortest input sequence ends. ``` fun <T, R, V> Sequence<T>.zip(     other: Sequence<R>,     transform: (a: T, b: R) -> V ): Sequence<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](zip-with-next) Returns a sequence of pairs of each two adjacent elements in this sequence. ``` fun <T> Sequence<T>.zipWithNext(): Sequence<Pair<T, T>> ``` Returns a sequence containing the results of applying the given [transform](zip-with-next#kotlin.sequences%24zipWithNext(kotlin.sequences.Sequence((kotlin.sequences.zipWithNext.T)),%20kotlin.Function2((kotlin.sequences.zipWithNext.T,%20,%20kotlin.sequences.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this sequence. ``` fun <T, R> Sequence<T>.zipWithNext(     transform: (a: T, b: T) -> R ): Sequence<R> ```
programming_docs
kotlin associateWith associateWith ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [associateWith](associate-with) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <K, V> Sequence<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) where keys are elements from the given sequence and values are produced by the [valueSelector](associate-with#kotlin.sequences%24associateWith(kotlin.sequences.Sequence((kotlin.sequences.associateWith.K)),%20kotlin.Function1((kotlin.sequences.associateWith.K,%20kotlin.sequences.associateWith.V)))/valueSelector) function applied to each element. If any two elements are equal, the last one gets added to the map. The returned map preserves the entry iteration order of the original sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val withLength = words.associateWith { it.length } println(withLength.keys) // [a, abc, ab, def, abcd] println(withLength.values) // [1, 3, 2, 3, 4] //sampleEnd } ``` kotlin orEmpty orEmpty ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [orEmpty](or-empty) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Sequence<T>?.orEmpty(): Sequence<T> ``` Returns this sequence if it's not `null` and the empty sequence otherwise. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nullSequence: Sequence<Int>? = null println(nullSequence.orEmpty().toList()) // [] val sequence: Sequence<Int>? = sequenceOf(1, 2, 3) println(sequence.orEmpty().toList()) // [1, 2, 3] //sampleEnd } ``` kotlin onEach onEach ====== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [onEach](on-each) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> Sequence<T>.onEach(action: (T) -> Unit): Sequence<T> ``` Returns a sequence which performs the given [action](on-each#kotlin.sequences%24onEach(kotlin.sequences.Sequence((kotlin.sequences.onEach.T)),%20kotlin.Function1((kotlin.sequences.onEach.T,%20kotlin.Unit)))/action) on each element of the original sequence as they pass through it. The operation is *intermediate* and *stateless*. kotlin scan scan ==== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <scan> **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T, R> Sequence<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): Sequence<R> ``` Returns a sequence containing successive accumulation values generated by applying [operation](scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/initial) value. Note that `acc` value passed to [operation](scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting sequence. The [initial](scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/initial) value should also be immutable (or should not be mutated) as it may be passed to [operation](scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/operation) function later because of sequence's lazy nature. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.scan("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.scanIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().scan("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. The operation is *intermediate* and *stateless*. kotlin lastOrNull lastOrNull ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [lastOrNull](last-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.lastOrNull(): T? ``` Returns the last element, or `null` if the sequence is empty. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.lastOrNull(     predicate: (T) -> Boolean ): T? ``` Returns the last element matching the given [predicate](last-or-null#kotlin.sequences%24lastOrNull(kotlin.sequences.Sequence((kotlin.sequences.lastOrNull.T)),%20kotlin.Function1((kotlin.sequences.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3, 4) println(list.last()) // 4 println(list.last { it % 2 == 1 }) // 3 println(list.lastOrNull { it < 0 }) // null // list.last { it < 0 } // will fail val emptyList = emptyList<Int>() println(emptyList.lastOrNull()) // null // emptyList.last() // will fail //sampleEnd } ``` kotlin mapIndexedTo mapIndexedTo ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [mapIndexedTo](map-indexed-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` Applies the given [transform](map-indexed-to#kotlin.sequences%24mapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedTo.T)),%20kotlin.sequences.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedTo.T,%20kotlin.sequences.mapIndexedTo.R)))/transform) function to each element and its index in the original sequence and appends the results to the given [destination](map-indexed-to#kotlin.sequences%24mapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedTo.T)),%20kotlin.sequences.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedTo.T,%20kotlin.sequences.mapIndexedTo.R)))/destination). Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. The operation is *terminal*. kotlin maxWithOrNull maxWithOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxWithOrNull](max-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` Returns the first element having the largest value according to the provided [comparator](max-with-or-null#kotlin.sequences%24maxWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxWithOrNull.T)))/comparator) or `null` if there are no elements. The operation is *terminal*. kotlin forEachIndexed forEachIndexed ============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [forEachIndexed](for-each-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` Performs the given [action](for-each-indexed#kotlin.sequences%24forEachIndexed(kotlin.sequences.Sequence((kotlin.sequences.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. Parameters ---------- `action` - function that takes the index of an element and the element itself and performs the action on the element. The operation is *terminal*. kotlin filterIndexed filterIndexed ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterIndexed](filter-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): Sequence<T> ``` Returns a sequence containing only elements matching the given [predicate](filter-indexed#kotlin.sequences%24filterIndexed(kotlin.sequences.Sequence((kotlin.sequences.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(0, 1, 2, 3, 4, 8, 6) val numbersOnSameIndexAsValue = numbers.filterIndexed { index, i -> index == i } println(numbersOnSameIndexAsValue) // [0, 1, 2, 3, 4, 6] //sampleEnd } ``` Parameters ---------- `predicate` - function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element. The operation is *intermediate* and *stateless*. kotlin sortedByDescending sortedByDescending ================== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [sortedByDescending](sorted-by-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Comparable<R>> Sequence<T>.sortedByDescending(     crossinline selector: (T) -> R? ): Sequence<T> ``` Returns a sequence that yields elements of this sequence sorted descending according to natural sort order of the value returned by specified [selector](sorted-by-descending#kotlin.sequences%24sortedByDescending(kotlin.sequences.Sequence((kotlin.sequences.sortedByDescending.T)),%20kotlin.Function1((kotlin.sequences.sortedByDescending.T,%20kotlin.sequences.sortedByDescending.R?)))/selector) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. The operation is *intermediate* and *stateful*. kotlin average average ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <average> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("averageOfByte") fun Sequence<Byte>.average(): Double ``` ``` @JvmName("averageOfShort") fun Sequence<Short>.average(): Double ``` ``` @JvmName("averageOfInt") fun Sequence<Int>.average(): Double ``` ``` @JvmName("averageOfLong") fun Sequence<Long>.average(): Double ``` ``` @JvmName("averageOfFloat") fun Sequence<Float>.average(): Double ``` ``` @JvmName("averageOfDouble") fun Sequence<Double>.average(): Double ``` Returns an average value of elements in the sequence. The operation is *terminal*. kotlin mapIndexedNotNull mapIndexedNotNull ================= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [mapIndexedNotNull](map-indexed-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, R : Any> Sequence<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): Sequence<R> ``` Returns a sequence containing only the non-null results of applying the given [transform](map-indexed-not-null#kotlin.sequences%24mapIndexedNotNull(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNull.T,%20kotlin.sequences.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original sequence. Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. The operation is *intermediate* and *stateless*. kotlin Sequence Sequence ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [Sequence](-sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence(     crossinline iterator: () -> Iterator<T> ): Sequence<T> ``` Given an [iterator](-sequence#kotlin.sequences%24Sequence(kotlin.Function0((kotlin.collections.Iterator((kotlin.sequences.Sequence.T)))))/iterator) function constructs a [Sequence](-sequence/index) that returns values through the [Iterator](../kotlin.collections/-iterator/index#kotlin.collections.Iterator) provided by that function. The values are evaluated lazily, and the sequence is potentially infinite. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf(1, 2, 3) // create a sequence with a function, returning an iterator val sequence1 = Sequence { array.iterator() } println(sequence1.joinToString()) // 1, 2, 3 println(sequence1.drop(1).joinToString()) // 2, 3 // create a sequence from an existing iterator // can be iterated only once val sequence2 = array.iterator().asSequence() println(sequence2.joinToString()) // 1, 2, 3 // sequence2.drop(1).joinToString() // <- iterating sequence second time will fail //sampleEnd } ``` kotlin toMutableSet toMutableSet ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [toMutableSet](to-mutable-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.toMutableSet(): MutableSet<T> ``` Returns a new [MutableSet](../kotlin.collections/-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given sequence. The returned set preserves the element iteration order of the original sequence. The operation is *terminal*. kotlin runningFold runningFold =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [runningFold](running-fold) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T, R> Sequence<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): Sequence<R> ``` Returns a sequence containing successive accumulation values generated by applying [operation](running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/initial) value. Note that `acc` value passed to [operation](running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting sequence. The [initial](running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/initial) value should also be immutable (or should not be mutated) as it may be passed to [operation](running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/operation) function later because of sequence's lazy nature. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningFold("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.runningFoldIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().runningFold("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. The operation is *intermediate* and *stateless*. kotlin mapIndexed mapIndexed ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [mapIndexed](map-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, R> Sequence<T>.mapIndexed(     transform: (index: Int, T) -> R ): Sequence<R> ``` Returns a sequence containing the results of applying the given [transform](map-indexed#kotlin.sequences%24mapIndexed(kotlin.sequences.Sequence((kotlin.sequences.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexed.T,%20kotlin.sequences.mapIndexed.R)))/transform) function to each element and its index in the original sequence. Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. The operation is *intermediate* and *stateless*. kotlin sortedBy sortedBy ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [sortedBy](sorted-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Comparable<R>> Sequence<T>.sortedBy(     crossinline selector: (T) -> R? ): Sequence<T> ``` Returns a sequence that yields elements of this sequence sorted according to natural sort order of the value returned by specified [selector](sorted-by#kotlin.sequences%24sortedBy(kotlin.sequences.Sequence((kotlin.sequences.sortedBy.T)),%20kotlin.Function1((kotlin.sequences.sortedBy.T,%20kotlin.sequences.sortedBy.R?)))/selector) function. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. The operation is *intermediate* and *stateful*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aaa", "cc", "bbbb") val sorted = list.sortedBy { it.length } println(list) // [aaa, cc, bbbb] println(sorted) // [cc, aaa, bbbb] //sampleEnd } ``` kotlin filterIsInstance filterIsInstance ================ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterIsInstance](filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <reified R> Sequence<*>.filterIsInstance(): Sequence<R> ``` Returns a sequence containing all elements that are instances of specified type parameter R. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart open class Animal(val name: String) { override fun toString(): String { return name } } class Dog(name: String): Animal(name) class Cat(name: String): Animal(name) val animals: List<Animal> = listOf(Cat("Scratchy"), Dog("Poochie")) val cats = animals.filterIsInstance<Cat>() println(cats) // [Scratchy] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0) ``` fun <R> Sequence<*>.filterIsInstance(     klass: Class<R> ): Sequence<R> ``` Returns a sequence containing all elements that are instances of specified class. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart open class Animal(val name: String) { override fun toString(): String { return name } } class Dog(name: String): Animal(name) class Cat(name: String): Animal(name) val animals: List<Animal> = listOf(Cat("Scratchy"), Dog("Poochie")) val cats = animals.filterIsInstance(Cat::class.java) println(cats) // [Scratchy] //sampleEnd } ```
programming_docs
kotlin filterNotNullTo filterNotNullTo =============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterNotNullTo](filter-not-null-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <C : MutableCollection<in T>, T : Any> Sequence<T?>.filterNotNullTo(     destination: C ): C ``` Appends all elements that are not `null` to the given [destination](filter-not-null-to#kotlin.sequences%24filterNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotNullTo.T?)),%20kotlin.sequences.filterNotNullTo.C)/destination). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int?> = listOf(1, 2, null, 4) val nonNullNumbers = mutableListOf<Int>() println(nonNullNumbers) // [] numbers.filterNotNullTo(nonNullNumbers) println(nonNullNumbers) // [1, 2, 4] //sampleEnd } ``` kotlin asIterable asIterable ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [asIterable](as-iterable) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.asIterable(): Iterable<T> ``` Creates an [Iterable](../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original sequence returning its elements when being iterated. kotlin lastIndexOf lastIndexOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [lastIndexOf](last-index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.lastIndexOf(element: T): Int ``` Returns last index of [element](last-index-of#kotlin.sequences%24lastIndexOf(kotlin.sequences.Sequence((kotlin.sequences.lastIndexOf.T)),%20kotlin.sequences.lastIndexOf.T)/element), or -1 if the sequence does not contain element. The operation is *terminal*. kotlin flatten flatten ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <flatten> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<Sequence<T>>.flatten(): Sequence<T> ``` Returns a sequence of all elements from all sequences in this sequence. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence: Sequence<Int> = generateSequence(1) { it + 1 } val sequenceOfSequences: Sequence<Sequence<Int>> = sequence.map { number -> generateSequence { number }.take(number) } println(sequenceOfSequences.flatten().take(10).toList()) // [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("flattenSequenceOfIterable") fun <T> Sequence<Iterable<T>>.flatten(): Sequence<T> ``` Returns a sequence of all elements from all iterables in this sequence. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence: Sequence<String> = sequenceOf("123", "45") val sequenceOfLists: Sequence<List<Char>> = sequence.map { it.toList() } println(sequenceOfLists.flatten().toList()) // [1, 2, 3, 4, 5] //sampleEnd } ``` kotlin count count ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <count> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.count(): Int ``` Returns the number of elements in this sequence. The operation is *terminal*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.count(     predicate: (T) -> Boolean ): Int ``` Returns the number of elements matching the given [predicate](count#kotlin.sequences%24count(kotlin.sequences.Sequence((kotlin.sequences.count.T)),%20kotlin.Function1((kotlin.sequences.count.T,%20kotlin.Boolean)))/predicate). The operation is *terminal*. kotlin flatMapIndexed flatMapIndexed ============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [flatMapIndexed](flat-map-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("flatMapIndexedIterable") fun <T, R> Sequence<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): Sequence<R> ``` ``` @JvmName("flatMapIndexedSequence") fun <T, R> Sequence<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): Sequence<R> ``` Returns a single sequence of all elements yielded from results of [transform](flat-map-indexed#kotlin.sequences%24flatMapIndexed(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original sequence. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val data: List<String> = listOf("Abcd", "efgh", "Klmn") val selected: List<Boolean> = data.map { it.any { c -> c.isUpperCase() } } val result = data.flatMapIndexed { index, s -> if (selected[index]) s.toList() else emptyList() } println(result) // [A, b, c, d, K, l, m, n] //sampleEnd } ``` kotlin windowed windowed ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <windowed> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T> Sequence<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): Sequence<List<T>> ``` Returns a sequence of snapshots of the window of the given [size](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this sequence with the given [step](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. Several last lists may have fewer elements than the given [size](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size). Both [size](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) and [step](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step) must be positive and can be greater than the number of elements in this sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = generateSequence(1) { it + 1 } val windows = sequence.windowed(size = 5, step = 1) println(windows.take(4).toList()) // [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]] val moreSparseWindows = sequence.windowed(size = 5, step = 3) println(moreSparseWindows.take(4).toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14]] val fullWindows = sequence.take(10).windowed(size = 5, step = 3) println(fullWindows.toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8]] val partialWindows = sequence.take(10).windowed(size = 5, step = 3, partialWindows = true) println(partialWindows.toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10], [10]] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each window `step` - the number of elements to move the window forward by on an each step, by default 1 `partialWindows` - controls whether or not to keep partial windows in the end if any, by default `false` which means partial windows won't be preserved **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T, R> Sequence<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): Sequence<R> ``` Returns a sequence of results of applying the given [transform](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/size) sliding along this sequence with the given [step](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/step). Note that the list passed to the [transform](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/transform) function is ephemeral and is valid only inside that function. You should not store it or allow it to escape in some way, unless you made a snapshot of it. Several last lists may have fewer elements than the given [size](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/size). Both [size](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/size) and [step](windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/step) must be positive and can be greater than the number of elements in this sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val dataPoints = sequenceOf(10, 15, 18, 25, 19, 21, 14, 8, 5) val averaged = dataPoints.windowed(size = 4, step = 1, partialWindows = true) { window -> window.average() } println(averaged.toList()) // [17.0, 19.25, 20.75, 19.75, 15.5, 12.0, 9.0, 6.5, 5.0] val averagedNoPartialWindows = dataPoints.windowed(size = 4, step = 1).map { it.average() } println(averagedNoPartialWindows.toList()) // [17.0, 19.25, 20.75, 19.75, 15.5, 12.0] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each window `step` - the number of elements to move the window forward by on an each step, by default 1 `partialWindows` - controls whether or not to keep partial windows in the end if any, by default `false` which means partial windows won't be preserved kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.asSequence(): Sequence<T> ``` Returns this sequence as a [Sequence](-sequence/index). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Iterator<T>.asSequence(): Sequence<T> ``` Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val array = arrayOf(1, 2, 3) // create a sequence with a function, returning an iterator val sequence1 = Sequence { array.iterator() } println(sequence1.joinToString()) // 1, 2, 3 println(sequence1.drop(1).joinToString()) // 2, 3 // create a sequence from an existing iterator // can be iterated only once val sequence2 = array.iterator().asSequence() println(sequence2.joinToString()) // 1, 2, 3 // sequence2.drop(1).joinToString() // <- iterating sequence second time will fail //sampleEnd } ``` kotlin scanIndexed scanIndexed =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [scanIndexed](scan-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T, R> Sequence<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): Sequence<R> ``` Returns a sequence containing successive accumulation values generated by applying [operation](scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with [initial](scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/initial) value. Note that `acc` value passed to [operation](scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting sequence. The [initial](scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/initial) value should also be immutable (or should not be mutated) as it may be passed to [operation](scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/operation) function later because of sequence's lazy nature. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.scan("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.scanIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().scan("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. The operation is *intermediate* and *stateless*. kotlin firstOrNull firstOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [firstOrNull](first-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.firstOrNull(): T? ``` Returns the first element, or `null` if the sequence is empty. The operation is *terminal*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` Returns the first element matching the given [predicate](first-or-null#kotlin.sequences%24firstOrNull(kotlin.sequences.Sequence((kotlin.sequences.firstOrNull.T)),%20kotlin.Function1((kotlin.sequences.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. The operation is *terminal*. kotlin maxOf maxOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxOf](max-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Sequence<T>.maxOf(     selector: (T) -> Double ): Double ``` ``` inline fun <T> Sequence<T>.maxOf(     selector: (T) -> Float ): Float ``` Returns the largest value among all values produced by [selector](max-of#kotlin.sequences%24maxOf(kotlin.sequences.Sequence((kotlin.sequences.maxOf.T)),%20kotlin.Function1((kotlin.sequences.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. If any of values produced by [selector](max-of#kotlin.sequences%24maxOf(kotlin.sequences.Sequence((kotlin.sequences.maxOf.T)),%20kotlin.Function1((kotlin.sequences.maxOf.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Sequence<T>.maxOf(     selector: (T) -> R ): R ``` Returns the largest value among all values produced by [selector](max-of#kotlin.sequences%24maxOf(kotlin.sequences.Sequence((kotlin.sequences.maxOf.T)),%20kotlin.Function1((kotlin.sequences.maxOf.T,%20kotlin.sequences.maxOf.R)))/selector) function applied to each element in the sequence. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. kotlin singleOrNull singleOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [singleOrNull](single-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.singleOrNull(): T? ``` Returns single element, or `null` if the sequence is empty or has more than one element. The operation is *terminal*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` Returns the single element matching the given [predicate](single-or-null#kotlin.sequences%24singleOrNull(kotlin.sequences.Sequence((kotlin.sequences.singleOrNull.T)),%20kotlin.Function1((kotlin.sequences.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. The operation is *terminal*. kotlin sum sum === [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <sum> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("sumOfByte") fun Sequence<Byte>.sum(): Int ``` ``` @JvmName("sumOfShort") fun Sequence<Short>.sum(): Int ``` ``` @JvmName("sumOfInt") fun Sequence<Int>.sum(): Int ``` ``` @JvmName("sumOfLong") fun Sequence<Long>.sum(): Long ``` ``` @JvmName("sumOfFloat") fun Sequence<Float>.sum(): Float ``` ``` @JvmName("sumOfDouble") fun Sequence<Double>.sum(): Double ``` ``` @JvmName("sumOfUInt") fun Sequence<UInt>.sum(): UInt ``` ``` @JvmName("sumOfULong") fun Sequence<ULong>.sum(): ULong ``` ``` @JvmName("sumOfUByte") fun Sequence<UByte>.sum(): UInt ``` ``` @JvmName("sumOfUShort") fun Sequence<UShort>.sum(): UInt ``` Returns the sum of all elements in the sequence. The operation is *terminal*. kotlin zip zip === [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <zip> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T, R> Sequence<T>.zip(     other: Sequence<R> ): Sequence<Pair<T, R>> ``` Returns a sequence of values built from the elements of `this` sequence and the [other](zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)))/other) sequence with the same index. The resulting sequence ends as soon as the shortest input sequence ends. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequenceA = ('a'..'z').asSequence() val sequenceB = generateSequence(1) { it * 2 + 1 } println((sequenceA zip sequenceB).take(4).toList()) // [(a, 1), (b, 3), (c, 7), (d, 15)] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, R, V> Sequence<T>.zip(     other: Sequence<R>,     transform: (a: T, b: R) -> V ): Sequence<V> ``` Returns a sequence of values built from the elements of `this` sequence and the [other](zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)),%20kotlin.Function2((kotlin.sequences.zip.T,%20kotlin.sequences.zip.R,%20kotlin.sequences.zip.V)))/other) sequence with the same index using the provided [transform](zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)),%20kotlin.Function2((kotlin.sequences.zip.T,%20kotlin.sequences.zip.R,%20kotlin.sequences.zip.V)))/transform) function applied to each pair of elements. The resulting sequence ends as soon as the shortest input sequence ends. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequenceA = ('a'..'z').asSequence() val sequenceB = generateSequence(1) { it * 2 + 1 } val result = sequenceA.zip(sequenceB) { a, b -> "$a/$b" } println(result.take(4).toList()) // [a/1, b/3, c/7, d/15] //sampleEnd } ```
programming_docs
kotlin groupBy groupBy ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [groupBy](group-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> Sequence<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups elements of the original sequence by the key returned by the given [keySelector](group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. The returned map preserves the entry iteration order of the keys produced from the original sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val byLength = words.groupBy { it.length } println(byLength.keys) // [1, 3, 2, 4] println(byLength.values) // [[a], [abc, def], [ab], [abcd]] val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } // same content as in byLength map, but the map is mutable println("mutableByLength == byLength is ${mutableByLength == byLength}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Sequence<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` Groups values returned by the [valueTransform](group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.V)))/valueTransform) function applied to each element of the original sequence by the key returned by the given [keySelector](group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. The returned map preserves the entry iteration order of the keys produced from the original sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing") val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first }) println(namesByTeam) // {Marketing=[Alice, Carol], Sales=[Bob]} val mutableNamesByTeam = nameToTeam.groupByTo(HashMap(), { it.second }, { it.first }) // same content as in namesByTeam map, but the map is mutable println("mutableNamesByTeam == namesByTeam is ${mutableNamesByTeam == namesByTeam}") // true //sampleEnd } ``` kotlin takeWhile takeWhile ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [takeWhile](take-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.takeWhile(     predicate: (T) -> Boolean ): Sequence<T> ``` Returns a sequence containing first elements satisfying the given [predicate](take-while#kotlin.sequences%24takeWhile(kotlin.sequences.Sequence((kotlin.sequences.takeWhile.T)),%20kotlin.Function1((kotlin.sequences.takeWhile.T,%20kotlin.Boolean)))/predicate). The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.take(3)) // [a, b, c] println(chars.takeWhile { it < 'f' }) // [a, b, c, d, e] println(chars.takeLast(2)) // [y, z] println(chars.takeLastWhile { it > 'w' }) // [x, y, z] //sampleEnd } ``` kotlin sumOf sumOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [sumOf](sum-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun <T> Sequence<T>.sumOf(     selector: (T) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun <T> Sequence<T>.sumOf(     selector: (T) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun <T> Sequence<T>.sumOf(     selector: (T) -> Long ): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun <T> Sequence<T>.sumOf(     selector: (T) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun <T> Sequence<T>.sumOf(     selector: (T) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun <T> Sequence<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun <T> Sequence<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` Returns the sum of all values produced by [selector](sum-of#kotlin.sequences%24sumOf(kotlin.sequences.Sequence((kotlin.sequences.sumOf.T)),%20kotlin.Function1((kotlin.sequences.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. The operation is *terminal*. kotlin toHashSet toHashSet ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [toHashSet](to-hash-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.toHashSet(): HashSet<T> ``` Returns a new [HashSet](../kotlin.collections/-hash-set/index#kotlin.collections.HashSet) of all elements. The operation is *terminal*. kotlin toSortedSet toSortedSet =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [toSortedSet](to-sorted-set) **Platform and version requirements:** JVM (1.0) ``` fun <T : Comparable<T>> Sequence<T>.toSortedSet(): SortedSet<T> ``` Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. The operation is *terminal*. **Platform and version requirements:** JVM (1.0) ``` fun <T> Sequence<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. Elements in the set returned are sorted according to the given [comparator](to-sorted-set#kotlin.sequences%24toSortedSet(kotlin.sequences.Sequence((kotlin.sequences.toSortedSet.T)),%20java.util.Comparator((kotlin.sequences.toSortedSet.T)))/comparator). The operation is *terminal*. kotlin maxWith maxWith ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxWith](max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("maxWithOrThrow") fun <T> Sequence<T>.maxWith(     comparator: Comparator<in T> ): T ``` Returns the first element having the largest value according to the provided [comparator](max-with#kotlin.sequences%24maxWith(kotlin.sequences.Sequence((kotlin.sequences.maxWith.T)),%20kotlin.Comparator((kotlin.sequences.maxWith.T)))/comparator). The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T> Sequence<T>.maxWith(     comparator: Comparator<in T> ): T? ``` **Deprecated:** Use maxWithOrNull instead. kotlin filterTo filterTo ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterTo](filter-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` Appends all elements matching the given [predicate](filter-to#kotlin.sequences%24filterTo(kotlin.sequences.Sequence((kotlin.sequences.filterTo.T)),%20kotlin.sequences.filterTo.C,%20kotlin.Function1((kotlin.sequences.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-to#kotlin.sequences%24filterTo(kotlin.sequences.Sequence((kotlin.sequences.filterTo.T)),%20kotlin.sequences.filterTo.C,%20kotlin.Function1((kotlin.sequences.filterTo.T,%20kotlin.Boolean)))/destination). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = mutableListOf<Int>() val notMultiplesOf3 = mutableListOf<Int>() println(evenNumbers) // [] numbers.filterTo(evenNumbers) { it % 2 == 0 } numbers.filterNotTo(notMultiplesOf3) { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` kotlin constrainOnce constrainOnce ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [constrainOnce](constrain-once) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.constrainOnce(): Sequence<T> ``` Returns a wrapper sequence that provides values of this sequence, but ensures it can be iterated only one time. The operation is *intermediate* and *stateless*. [IllegalStateException](../kotlin/-illegal-state-exception/index#kotlin.IllegalStateException) is thrown on iterating the returned sequence for the second time and the following times. kotlin flatMap flatMap ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [flatMap](flat-map) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("flatMapIterable") fun <T, R> Sequence<T>.flatMap(     transform: (T) -> Iterable<R> ): Sequence<R> ``` ``` fun <T, R> Sequence<T>.flatMap(     transform: (T) -> Sequence<R> ): Sequence<R> ``` Returns a single sequence of all elements from results of [transform](flat-map#kotlin.sequences%24flatMap(kotlin.sequences.Sequence((kotlin.sequences.flatMap.T)),%20kotlin.Function1((kotlin.sequences.flatMap.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMap.R)))))/transform) function being invoked on each element of original sequence. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("123", "45") println(list.flatMap { it.toList() }) // [1, 2, 3, 4, 5] //sampleEnd } ``` kotlin minBy minBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minBy](min-by) **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <T, R : Comparable<R>> Sequence<T>.minBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <T, R : Comparable<R>> Sequence<T>.minBy(     selector: (T) -> R ): T? ``` **Deprecated:** Use minByOrNull instead. Returns the first element yielding the smallest value of the given function. The operation is *terminal*. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.minBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the sequence is empty. kotlin dropWhile dropWhile ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [dropWhile](drop-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.dropWhile(     predicate: (T) -> Boolean ): Sequence<T> ``` Returns a sequence containing all elements except first elements that satisfy the given [predicate](drop-while#kotlin.sequences%24dropWhile(kotlin.sequences.Sequence((kotlin.sequences.dropWhile.T)),%20kotlin.Function1((kotlin.sequences.dropWhile.T,%20kotlin.Boolean)))/predicate). The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = ('a'..'z').toList() println(chars.drop(23)) // [x, y, z] println(chars.dropLast(23)) // [a, b, c] println(chars.dropWhile { it < 'x' }) // [x, y, z] println(chars.dropLastWhile { it > 'c' }) // [a, b, c] //sampleEnd } ``` kotlin minusElement minusElement ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minusElement](minus-element) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.minusElement(element: T): Sequence<T> ``` Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element](minus-element#kotlin.sequences%24minusElement(kotlin.sequences.Sequence((kotlin.sequences.minusElement.T)),%20kotlin.sequences.minusElement.T)/element). The operation is *intermediate* and *stateless*. kotlin find find ==== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <find> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.find(     predicate: (T) -> Boolean ): T? ``` Returns the first element matching the given [predicate](find#kotlin.sequences%24find(kotlin.sequences.Sequence((kotlin.sequences.find.T)),%20kotlin.Function1((kotlin.sequences.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3, 4, 5, 6, 7) val firstOdd = numbers.find { it % 2 != 0 } val lastEven = numbers.findLast { it % 2 == 0 } println(firstOdd) // 1 println(lastEven) // 6 //sampleEnd } ``` kotlin elementAtOrNull elementAtOrNull =============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [elementAtOrNull](element-at-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.elementAtOrNull(index: Int): T? ``` Returns an element at the given [index](element-at-or-null#kotlin.sequences%24elementAtOrNull(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.sequences%24elementAtOrNull(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrNull(0)) // 1 println(list.elementAtOrNull(2)) // 3 println(list.elementAtOrNull(3)) // null val emptyList = emptyList<Int>() println(emptyList.elementAtOrNull(0)) // null //sampleEnd } ``` kotlin unzip unzip ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <unzip> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, R> Sequence<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` Returns a pair of lists, where *first* list is built from the first values of each pair from this sequence, *second* list is built from the second values of each pair from this sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val result = generateSequence(0 to 1) { it.first + 1 to it.second * 2 }.take(8).unzip() println(result.first.toList()) // [0, 1, 2, 3, 4, 5, 6, 7] println(result.second.toList()) // [1, 2, 4, 8, 16, 32, 64, 128] //sampleEnd } ``` kotlin maxBy maxBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxBy](max-by) **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <T, R : Comparable<R>> Sequence<T>.maxBy(     selector: (T) -> R ): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <T, R : Comparable<R>> Sequence<T>.maxBy(     selector: (T) -> R ): T? ``` **Deprecated:** Use maxByOrNull instead. Returns the first element yielding the largest value of the given function. The operation is *terminal*. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.maxBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the sequence is empty. kotlin requireNoNulls requireNoNulls ============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [requireNoNulls](require-no-nulls) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> ``` Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. The operation is *intermediate* and *stateless*. kotlin sumBy sumBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [sumBy](sum-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") inline fun <T> Sequence<T>.sumBy(     selector: (T) -> Int ): Int ``` **Deprecated:** Use sumOf instead. Returns the sum of all values produced by [selector](sum-by#kotlin.sequences%24sumBy(kotlin.sequences.Sequence((kotlin.sequences.sumBy.T)),%20kotlin.Function1((kotlin.sequences.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the sequence. The operation is *terminal*. kotlin reduce reduce ====== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <reduce> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <S, T : S> Sequence<T>.reduce(     operation: (acc: S, T) -> S ): S ``` Accumulates value starting with the first element and applying [operation](reduce#kotlin.sequences%24reduce(kotlin.sequences.Sequence((kotlin.sequences.reduce.T)),%20kotlin.Function2((kotlin.sequences.reduce.S,%20kotlin.sequences.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. Throws an exception if this sequence is empty. If the sequence can be empty in an expected way, please use [reduceOrNull](reduce-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduce { acc, string -> acc + string }) // abcd println(strings.reduceIndexed { index, acc, string -> acc + string + index }) // ab1c2d3 // emptyList<Int>().reduce { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. The operation is *terminal*. kotlin toCollection toCollection ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [toCollection](to-collection) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T, C : MutableCollection<in T>> Sequence<T>.toCollection(     destination: C ): C ``` Appends all elements to the given [destination](to-collection#kotlin.sequences%24toCollection(kotlin.sequences.Sequence((kotlin.sequences.toCollection.T)),%20kotlin.sequences.toCollection.C)/destination) collection. The operation is *terminal*. kotlin maxOfOrNull maxOfOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxOfOrNull](max-of-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Sequence<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` inline fun <T> Sequence<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.sequences%24maxOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the sequence or `null` if there are no elements. If any of values produced by [selector](max-of-or-null#kotlin.sequences%24maxOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.maxOfOrNull.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. The operation is *terminal*. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Sequence<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.sequences%24maxOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.maxOfOrNull.T,%20kotlin.sequences.maxOfOrNull.R)))/selector) function applied to each element in the sequence or `null` if there are no elements. The operation is *terminal*.
programming_docs
kotlin firstNotNullOfOrNull firstNotNullOfOrNull ==================== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [firstNotNullOfOrNull](first-not-null-of-or-null) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <T, R : Any> Sequence<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.sequences%24firstNotNullOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.firstNotNullOfOrNull.T,%20kotlin.sequences.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this sequence in iteration order, or `null` if no non-null value was produced. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` kotlin iterator iterator ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <iterator> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> iterator(     block: suspend SequenceScope<T>.() -> Unit ): Iterator<T> ``` Builds an [Iterator](../kotlin.collections/-iterator/index#kotlin.collections.Iterator) lazily yielding values one by one. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val collection = listOf(1, 2, 3) val wrappedCollection = object : AbstractCollection<Any>() { override val size: Int = collection.size + 2 override fun iterator(): Iterator<Any> = iterator { yield("first") yieldAll(collection) yield("last") } } println(wrappedCollection) // [first, 1, 2, 3, last] //sampleEnd } ``` ``` fun main(args: Array<String>) { //sampleStart val iterable = Iterable { iterator { yield(42) yieldAll(1..5 step 2) } } val result = iterable.mapIndexed { index, value -> "$index: $value" } println(result) // [0: 42, 1: 1, 2: 3, 3: 5] // can be iterated many times repeat(2) { val sum = iterable.sum() println(sum) // 51 } //sampleEnd } ``` kotlin minWith minWith ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minWith](min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("minWithOrThrow") fun <T> Sequence<T>.minWith(     comparator: Comparator<in T> ): T ``` Returns the first element having the smallest value according to the provided [comparator](min-with#kotlin.sequences%24minWith(kotlin.sequences.Sequence((kotlin.sequences.minWith.T)),%20kotlin.Comparator((kotlin.sequences.minWith.T)))/comparator). The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T> Sequence<T>.minWith(     comparator: Comparator<in T> ): T? ``` **Deprecated:** Use minWithOrNull instead. kotlin shuffled shuffled ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <shuffled> **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.shuffled(): Sequence<T> ``` Returns a sequence that yields elements of this sequence randomly shuffled. Note that every iteration of the sequence returns elements in a different order. The operation is *intermediate* and *stateful*. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.shuffled(random: Random): Sequence<T> ``` Returns a sequence that yields elements of this sequence randomly shuffled using the specified [random](shuffled#kotlin.sequences%24shuffled(kotlin.sequences.Sequence((kotlin.sequences.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. Note that every iteration of the sequence returns elements in a different order. The operation is *intermediate* and *stateful*. kotlin minOf minOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minOf](min-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Sequence<T>.minOf(     selector: (T) -> Double ): Double ``` ``` inline fun <T> Sequence<T>.minOf(     selector: (T) -> Float ): Float ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.sequences%24minOf(kotlin.sequences.Sequence((kotlin.sequences.minOf.T)),%20kotlin.Function1((kotlin.sequences.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. If any of values produced by [selector](min-of#kotlin.sequences%24minOf(kotlin.sequences.Sequence((kotlin.sequences.minOf.T)),%20kotlin.Function1((kotlin.sequences.minOf.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Sequence<T>.minOf(     selector: (T) -> R ): R ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.sequences%24minOf(kotlin.sequences.Sequence((kotlin.sequences.minOf.T)),%20kotlin.Function1((kotlin.sequences.minOf.T,%20kotlin.sequences.minOf.R)))/selector) function applied to each element in the sequence. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. kotlin max max === [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <max> **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun Sequence<Double>.max(): Double ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Sequence<Double>.max(): Double? ``` **Deprecated:** Use maxOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun Sequence<Float>.max(): Float ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Sequence<Float>.max(): Float? ``` **Deprecated:** Use maxOrNull instead. Returns the largest element. If any of elements is `NaN` returns `NaN`. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun <T : Comparable<T>> Sequence<T>.max(): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T : Comparable<T>> Sequence<T>.max(): T? ``` **Deprecated:** Use maxOrNull instead. Returns the largest element. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. kotlin indexOfFirst indexOfFirst ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [indexOfFirst](index-of-first) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` Returns index of the first element matching the given [predicate](index-of-first#kotlin.sequences%24indexOfFirst(kotlin.sequences.Sequence((kotlin.sequences.indexOfFirst.T)),%20kotlin.Function1((kotlin.sequences.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the sequence does not contain such element. The operation is *terminal*. kotlin groupingBy groupingBy ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [groupingBy](grouping-by) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T, K> Sequence<T>.groupingBy(     crossinline keySelector: (T) -> K ): Grouping<T, K> ``` Creates a [Grouping](../kotlin.collections/-grouping/index) source from a sequence to be used later with one of group-and-fold operations using the specified [keySelector](grouping-by#kotlin.sequences%24groupingBy(kotlin.sequences.Sequence((kotlin.sequences.groupingBy.T)),%20kotlin.Function1((kotlin.sequences.groupingBy.T,%20kotlin.sequences.groupingBy.K)))/keySelector) function to extract a key from each element. The operation is *intermediate* and *stateless*. ``` fun main(args: Array<String>) { //sampleStart val words = "one two three four five six seven eight nine ten".split(' ') val frequenciesByFirstChar = words.groupingBy { it.first() }.eachCount() println("Counting first letters:") println(frequenciesByFirstChar) // {o=1, t=3, f=2, s=2, e=1, n=1} val moreWords = "eleven twelve".split(' ') val moreFrequencies = moreWords.groupingBy { it.first() }.eachCountTo(frequenciesByFirstChar.toMutableMap()) println(moreFrequencies) // {o=1, t=4, f=2, s=2, e=2, n=1} //sampleEnd } ``` kotlin flatMapTo flatMapTo ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [flatMapTo](flat-map-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("flatMapIterableTo") inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-to#kotlin.sequences%24flatMapTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapTo.T)),%20kotlin.sequences.flatMapTo.C,%20kotlin.Function1((kotlin.sequences.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapTo.R)))))/transform) function being invoked on each element of original sequence, to the given [destination](flat-map-to#kotlin.sequences%24flatMapTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapTo.T)),%20kotlin.sequences.flatMapTo.C,%20kotlin.Function1((kotlin.sequences.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapTo.R)))))/destination). The operation is *terminal*. kotlin toSet toSet ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [toSet](to-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.toSet(): Set<T> ``` Returns a [Set](../kotlin.collections/-set/index#kotlin.collections.Set) of all elements. The returned set preserves the element iteration order of the original sequence. The operation is *terminal*. kotlin minByOrNull minByOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minByOrNull](min-by-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Sequence<T>.minByOrNull(     selector: (T) -> R ): T? ``` Returns the first element yielding the smallest value of the given function or `null` if there are no elements. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("abcd", "abc", "ab", "abcde") val shortestString = list.minByOrNull { it.length } println(shortestString) // ab val emptyList = emptyList<String>() val emptyMin = emptyList.minByOrNull { it.length } println(emptyMin) // null //sampleEnd } ``` kotlin minWithOrNull minWithOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minWithOrNull](min-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` Returns the first element having the smallest value according to the provided [comparator](min-with-or-null#kotlin.sequences%24minWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minWithOrNull.T)))/comparator) or `null` if there are no elements. The operation is *terminal*. kotlin min min === [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <min> **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun Sequence<Double>.min(): Double ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Sequence<Double>.min(): Double? ``` **Deprecated:** Use minOrNull instead. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun Sequence<Float>.min(): Float ``` **Platform and version requirements:** JVM (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun Sequence<Float>.min(): Float? ``` **Deprecated:** Use minOrNull instead. Returns the smallest element. If any of elements is `NaN` returns `NaN`. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun <T : Comparable<T>> Sequence<T>.min(): T ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun <T : Comparable<T>> Sequence<T>.min(): T? ``` **Deprecated:** Use minOrNull instead. Returns the smallest element. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. kotlin associateBy associateBy =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [associateBy](associate-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> Sequence<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing the elements from the given sequence indexed by the key returned from [keySelector](associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)))/keySelector) function applied to each element. If any two elements would have the same key returned by [keySelector](associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)))/keySelector) the last one gets added to the map. The returned map preserves the entry iteration order of the original sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = scientists.associateBy { it.lastName } // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace Hopper, Bernoulli=Johann Bernoulli} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Sequence<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.V)))/valueTransform) and indexed by [keySelector](associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.V)))/keySelector) functions applied to elements of the given sequence. If any two elements would have the same key returned by [keySelector](associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.V)))/keySelector) the last one gets added to the map. The returned map preserves the entry iteration order of the original sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = scientists.associateBy({ it.lastName }, { it.firstName }) // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace, Bernoulli=Johann} //sampleEnd } ``` kotlin filterNotTo filterNotTo =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterNotTo](filter-not-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` Appends all elements not matching the given [predicate](filter-not-to#kotlin.sequences%24filterNotTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotTo.T)),%20kotlin.sequences.filterNotTo.C,%20kotlin.Function1((kotlin.sequences.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-not-to#kotlin.sequences%24filterNotTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotTo.T)),%20kotlin.sequences.filterNotTo.C,%20kotlin.Function1((kotlin.sequences.filterNotTo.T,%20kotlin.Boolean)))/destination). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = mutableListOf<Int>() val notMultiplesOf3 = mutableListOf<Int>() println(evenNumbers) // [] numbers.filterTo(evenNumbers) { it % 2 == 0 } numbers.filterNotTo(notMultiplesOf3) { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` kotlin generateSequence generateSequence ================ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [generateSequence](generate-sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> generateSequence(     nextFunction: () -> T? ): Sequence<T> ``` Returns a sequence which invokes the function to calculate the next value on each iteration until the function returns `null`. The returned sequence is constrained to be iterated only once. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart var count = 3 val sequence = generateSequence { (count--).takeIf { it > 0 } // will return null, when value becomes non-positive, // and that will terminate the sequence } println(sequence.toList()) // [3, 2, 1] // sequence.forEach { } // <- iterating that sequence second time will fail //sampleEnd } ``` **See Also** [constrainOnce](constrain-once) [kotlin.sequences.sequence](sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> generateSequence(     seed: T?,     nextFunction: (T) -> T? ): Sequence<T> ``` Returns a sequence defined by the starting value [seed](generate-sequence#kotlin.sequences%24generateSequence(kotlin.sequences.generateSequence.T?,%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/seed) and the function [nextFunction](generate-sequence#kotlin.sequences%24generateSequence(kotlin.sequences.generateSequence.T?,%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/nextFunction), which is invoked to calculate the next value based on the previous one on each iteration. The sequence produces values until it encounters first `null` value. If [seed](generate-sequence#kotlin.sequences%24generateSequence(kotlin.sequences.generateSequence.T?,%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/seed) is `null`, an empty sequence is produced. The sequence can be iterated multiple times, each time starting with [seed](generate-sequence#kotlin.sequences%24generateSequence(kotlin.sequences.generateSequence.T?,%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/seed). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun fibonacci(): Sequence<Int> { // fibonacci terms // 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, ... return generateSequence(Pair(0, 1), { Pair(it.second, it.first + it.second) }).map { it.first } } println(fibonacci().take(10).toList()) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] //sampleEnd } ``` **See Also** [kotlin.sequences.sequence](sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> generateSequence(     seedFunction: () -> T?,     nextFunction: (T) -> T? ): Sequence<T> ``` Returns a sequence defined by the function [seedFunction](generate-sequence#kotlin.sequences%24generateSequence(kotlin.Function0((kotlin.sequences.generateSequence.T?)),%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/seedFunction), which is invoked to produce the starting value, and the [nextFunction](generate-sequence#kotlin.sequences%24generateSequence(kotlin.Function0((kotlin.sequences.generateSequence.T?)),%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/nextFunction), which is invoked to calculate the next value based on the previous one on each iteration. The sequence produces values until it encounters first `null` value. If [seedFunction](generate-sequence#kotlin.sequences%24generateSequence(kotlin.Function0((kotlin.sequences.generateSequence.T?)),%20kotlin.Function1((kotlin.sequences.generateSequence.T,%20kotlin.sequences.generateSequence.T?)))/seedFunction) returns `null`, an empty sequence is produced. The sequence can be iterated multiple times. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart class LinkedValue<T>(val value: T, val next: LinkedValue<T>? = null) fun <T> LinkedValue<T>?.asSequence(): Sequence<LinkedValue<T>> = generateSequence( seedFunction = { this }, nextFunction = { it.next } ) fun <T> LinkedValue<T>?.valueSequence(): Sequence<T> = asSequence().map { it.value } val singleItem = LinkedValue(42) val twoItems = LinkedValue(24, singleItem) println(twoItems.valueSequence().toList()) // [24, 42] println(singleItem.valueSequence().toList()) // [42] println(singleItem.next.valueSequence().toList()) // [] //sampleEnd } ``` **See Also** [kotlin.sequences.sequence](sequence)
programming_docs
kotlin flatMapIndexedTo flatMapIndexedTo ================ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [flatMapIndexedTo](flat-map-indexed-to) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("flatMapIndexedIterableTo") inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` @JvmName("flatMapIndexedSequenceTo") inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-indexed-to#kotlin.sequences%24flatMapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexedTo.T)),%20kotlin.sequences.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original sequence, to the given [destination](flat-map-indexed-to#kotlin.sequences%24flatMapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexedTo.T)),%20kotlin.sequences.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexedTo.R)))))/destination). The operation is *terminal*. kotlin minOfWithOrNull minOfWithOrNull =============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minOfWithOrNull](min-of-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Sequence<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.sequences%24minOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.minOfWithOrNull.T,%20kotlin.sequences.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.sequences%24minOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.minOfWithOrNull.T,%20kotlin.sequences.minOfWithOrNull.R)))/selector) function applied to each element in the sequence or `null` if there are no elements. The operation is *terminal*. kotlin partition partition ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <partition> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` Splits the original sequence into pair of lists, where *first* list contains elements for which [predicate](partition#kotlin.sequences%24partition(kotlin.sequences.Sequence((kotlin.sequences.partition.T)),%20kotlin.Function1((kotlin.sequences.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](partition#kotlin.sequences%24partition(kotlin.sequences.Sequence((kotlin.sequences.partition.T)),%20kotlin.Function1((kotlin.sequences.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun fibonacci(): Sequence<Int> { // fibonacci terms // 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, ... return generateSequence(Pair(0, 1), { Pair(it.second, it.first + it.second) }).map { it.first } } val (even, odd) = fibonacci().take(10).partition { it % 2 == 0 } println(even) // [0, 2, 8, 34] println(odd) // [1, 1, 3, 5, 13, 21] //sampleEnd } ``` kotlin onEachIndexed onEachIndexed ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [onEachIndexed](on-each-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.onEachIndexed(     action: (index: Int, T) -> Unit ): Sequence<T> ``` Returns a sequence which performs the given [action](on-each-indexed#kotlin.sequences%24onEachIndexed(kotlin.sequences.Sequence((kotlin.sequences.onEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.onEachIndexed.T,%20kotlin.Unit)))/action) on each element of the original sequence as they pass through it. Parameters ---------- `action` - function that takes the index of an element and the element itself and performs the action on the element. The operation is *intermediate* and *stateless*. kotlin indexOfLast indexOfLast =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [indexOfLast](index-of-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` Returns index of the last element matching the given [predicate](index-of-last#kotlin.sequences%24indexOfLast(kotlin.sequences.Sequence((kotlin.sequences.indexOfLast.T)),%20kotlin.Function1((kotlin.sequences.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the sequence does not contain such element. The operation is *terminal*. kotlin runningFoldIndexed runningFoldIndexed ================== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [runningFoldIndexed](running-fold-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T, R> Sequence<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): Sequence<R> ``` Returns a sequence containing successive accumulation values generated by applying [operation](running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with [initial](running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/initial) value. Note that `acc` value passed to [operation](running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting sequence. The [initial](running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/initial) value should also be immutable (or should not be mutated) as it may be passed to [operation](running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/operation) function later because of sequence's lazy nature. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningFold("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.runningFoldIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().runningFold("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. The operation is *intermediate* and *stateless*. kotlin none none ==== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <none> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.none(): Boolean ``` Returns `true` if the sequence has no elements. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.none() is ${emptyList.none()}") // true val nonEmptyList = listOf("one", "two", "three") println("nonEmptyList.none() is ${nonEmptyList.none()}") // false //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.none(     predicate: (T) -> Boolean ): Boolean ``` Returns `true` if no elements match the given [predicate](none#kotlin.sequences%24none(kotlin.sequences.Sequence((kotlin.sequences.none.T)),%20kotlin.Function1((kotlin.sequences.none.T,%20kotlin.Boolean)))/predicate). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.none { isEven(it) } is ${zeroToTen.none { isEven(it) }}") // false println("zeroToTen.none(isEven) is ${zeroToTen.none(isEven)}") // false val odds = zeroToTen.map { it * 2 + 1 } println("odds.none { isEven(it) } is ${odds.none { isEven(it) }}") // true val emptyList = emptyList<Int>() println("emptyList.none { true } is ${emptyList.none { true }}") // true //sampleEnd } ``` kotlin maxByOrNull maxByOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxByOrNull](max-by-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Sequence<T>.maxByOrNull(     selector: (T) -> R ): T? ``` Returns the first element yielding the largest value of the given function or `null` if there are no elements. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToAge = listOf("Alice" to 42, "Bob" to 28, "Carol" to 51) val oldestPerson = nameToAge.maxByOrNull { it.second } println(oldestPerson) // (Carol, 51) val emptyList = emptyList<Pair<String, Int>>() val emptyMax = emptyList.maxByOrNull { it.second } println(emptyMax) // null //sampleEnd } ``` kotlin maxOrNull maxOrNull ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxOrNull](max-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Sequence<Double>.maxOrNull(): Double? ``` ``` fun Sequence<Float>.maxOrNull(): Float? ``` Returns the largest element or `null` if there are no elements. If any of elements is `NaN` returns `NaN`. The operation is *terminal*. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Comparable<T>> Sequence<T>.maxOrNull(): T? ``` Returns the largest element or `null` if there are no elements. The operation is *terminal*. kotlin findLast findLast ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [findLast](find-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.findLast(     predicate: (T) -> Boolean ): T? ``` Returns the last element matching the given [predicate](find-last#kotlin.sequences%24findLast(kotlin.sequences.Sequence((kotlin.sequences.findLast.T)),%20kotlin.Function1((kotlin.sequences.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3, 4, 5, 6, 7) val firstOdd = numbers.find { it % 2 != 0 } val lastEven = numbers.findLast { it % 2 == 0 } println(firstOdd) // 1 println(lastEven) // 6 //sampleEnd } ``` kotlin fold fold ==== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <fold> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> Sequence<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` Accumulates value starting with [initial](fold#kotlin.sequences%24fold(kotlin.sequences.Sequence((kotlin.sequences.fold.T)),%20kotlin.sequences.fold.R,%20kotlin.Function2((kotlin.sequences.fold.R,%20kotlin.sequences.fold.T,%20)))/initial) value and applying [operation](fold#kotlin.sequences%24fold(kotlin.sequences.Sequence((kotlin.sequences.fold.T)),%20kotlin.sequences.fold.R,%20kotlin.Function2((kotlin.sequences.fold.R,%20kotlin.sequences.fold.T,%20)))/operation) from left to right to current accumulator value and each element. Returns the specified [initial](fold#kotlin.sequences%24fold(kotlin.sequences.Sequence((kotlin.sequences.fold.T)),%20kotlin.sequences.fold.R,%20kotlin.Function2((kotlin.sequences.fold.R,%20kotlin.sequences.fold.T,%20)))/initial) value if the sequence is empty. Parameters ---------- `operation` - function that takes current accumulator value and an element, and calculates the next accumulator value. The operation is *terminal*. kotlin minOrNull minOrNull ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minOrNull](min-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Sequence<Double>.minOrNull(): Double? ``` ``` fun Sequence<Float>.minOrNull(): Float? ``` Returns the smallest element or `null` if there are no elements. If any of elements is `NaN` returns `NaN`. The operation is *terminal*. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Comparable<T>> Sequence<T>.minOrNull(): T? ``` Returns the smallest element or `null` if there are no elements. The operation is *terminal*. kotlin minus minus ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.minus(element: T): Sequence<T> ``` Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.sequences.minus.T)/element). The operation is *intermediate* and *stateless*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.minus(     elements: Array<out T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.Array((kotlin.sequences.minus.T)))/elements) array. Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. The operation is *intermediate* and *stateful*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.minus(     elements: Iterable<T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.collections.Iterable((kotlin.sequences.minus.T)))/elements) collection. Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. The operation is *intermediate* and *stateful*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.minus(     elements: Sequence<T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.sequences.Sequence((kotlin.sequences.minus.T)))/elements) sequence. Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. The operation is *intermediate* for this sequence and *terminal* and *stateful* for the [elements](minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.sequences.Sequence((kotlin.sequences.minus.T)))/elements) sequence. kotlin filterIndexedTo filterIndexedTo =============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterIndexedTo](filter-indexed-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` Appends all elements matching the given [predicate](filter-indexed-to#kotlin.sequences%24filterIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.filterIndexedTo.T)),%20kotlin.sequences.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](filter-indexed-to#kotlin.sequences%24filterIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.filterIndexedTo.T)),%20kotlin.sequences.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(0, 1, 2, 3, 4, 8, 6) val numbersOnSameIndexAsValue = mutableListOf<Int>() println(numbersOnSameIndexAsValue) // [] numbers.filterIndexedTo(numbersOnSameIndexAsValue) { index, i -> index == i } println(numbersOnSameIndexAsValue) // [0, 1, 2, 3, 4, 6] //sampleEnd } ``` Parameters ---------- `predicate` - function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element. The operation is *terminal*. kotlin mapIndexedNotNullTo mapIndexedNotNullTo =================== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [mapIndexedNotNullTo](map-indexed-not-null-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` Applies the given [transform](map-indexed-not-null-to#kotlin.sequences%24mapIndexedNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNullTo.T)),%20kotlin.sequences.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNullTo.T,%20kotlin.sequences.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original sequence and appends only the non-null results to the given [destination](map-indexed-not-null-to#kotlin.sequences%24mapIndexedNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNullTo.T)),%20kotlin.sequences.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNullTo.T,%20kotlin.sequences.mapIndexedNotNullTo.R?)))/destination). Parameters ---------- `transform` - function that takes the index of an element and the element itself and returns the result of the transform applied to the element. The operation is *terminal*.
programming_docs
kotlin elementAt elementAt ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [elementAt](element-at) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.elementAt(index: Int): T ``` Returns an element at the given [index](element-at#kotlin.sequences%24elementAt(kotlin.sequences.Sequence((kotlin.sequences.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.sequences%24elementAt(kotlin.sequences.Sequence((kotlin.sequences.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAt(0)) // 1 println(list.elementAt(2)) // 3 // list.elementAt(3) // will fail with IndexOutOfBoundsException val emptyList = emptyList<Int>() // emptyList.elementAt(0) // will fail with IndexOutOfBoundsException //sampleEnd } ``` kotlin emptySequence emptySequence ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [emptySequence](empty-sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> emptySequence(): Sequence<T> ``` Returns an empty sequence. kotlin joinToString joinToString ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [joinToString](join-to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` Creates a string from all the elements separated using [separator](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. If the collection could be huge, you can specify a non-negative value of [limit](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/limit), in which case only the first [limit](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/limit) elements will be appended, followed by the [truncated](join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/truncated) string (which defaults to "..."). The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3, 4, 5, 6) println(numbers.joinToString()) // 1, 2, 3, 4, 5, 6 println(numbers.joinToString(prefix = "[", postfix = "]")) // [1, 2, 3, 4, 5, 6] println(numbers.joinToString(prefix = "<", postfix = ">", separator = "•")) // <1•2•3•4•5•6> val chars = charArrayOf('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q') println(chars.joinToString(limit = 5, truncated = "...!") { it.uppercaseChar().toString() }) // A, B, C, D, E, ...! //sampleEnd } ``` kotlin maxOfWith maxOfWith ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [maxOfWith](max-of-with) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Sequence<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` Returns the largest value according to the provided [comparator](max-of-with#kotlin.sequences%24maxOfWith(kotlin.sequences.Sequence((kotlin.sequences.maxOfWith.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWith.R)),%20kotlin.Function1((kotlin.sequences.maxOfWith.T,%20kotlin.sequences.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.sequences%24maxOfWith(kotlin.sequences.Sequence((kotlin.sequences.maxOfWith.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWith.R)),%20kotlin.Function1((kotlin.sequences.maxOfWith.T,%20kotlin.sequences.maxOfWith.R)))/selector) function applied to each element in the sequence. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. The operation is *terminal*. kotlin minOfWith minOfWith ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minOfWith](min-of-with) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R> Sequence<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` Returns the smallest value according to the provided [comparator](min-of-with#kotlin.sequences%24minOfWith(kotlin.sequences.Sequence((kotlin.sequences.minOfWith.T)),%20kotlin.Comparator((kotlin.sequences.minOfWith.R)),%20kotlin.Function1((kotlin.sequences.minOfWith.T,%20kotlin.sequences.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.sequences%24minOfWith(kotlin.sequences.Sequence((kotlin.sequences.minOfWith.T)),%20kotlin.Comparator((kotlin.sequences.minOfWith.R)),%20kotlin.Function1((kotlin.sequences.minOfWith.T,%20kotlin.sequences.minOfWith.R)))/selector) function applied to each element in the sequence. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. The operation is *terminal*. kotlin chunked chunked ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <chunked> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> ``` Splits this sequence into a sequence of lists each not exceeding the given [size](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int)/size). The last list in the resulting sequence may have fewer elements than the given [size](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int)/size). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = "one two three four five six seven eight nine ten".split(' ') val chunks = words.chunked(3) println(chunks) // [[one, two, three], [four, five, six], [seven, eight, nine], [ten]] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. The operation is *intermediate* and *stateful*. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T, R> Sequence<T>.chunked(     size: Int,     transform: (List<T>) -> R ): Sequence<R> ``` Splits this sequence into several lists each not exceeding the given [size](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/size) and applies the given [transform](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/transform) function to an each. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine") val dnaFragment = "ATTCGCGGCCGCCAA" val proteins = dnaFragment.chunked(3) { codon: CharSequence -> codonTable[codon.toString()] ?: error("Unknown codon") } println(proteins) // [Isoleucine, Arginine, Glycine, Arginine, Glutamine] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence. The operation is *intermediate* and *stateful*. **Return** sequence of results of the [transform](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/transform) applied to an each list. Note that the list passed to the [transform](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/transform) function is ephemeral and is valid only inside that function. You should not store it or allow it to escape in some way, unless you made a snapshot of it. The last list may have fewer elements than the given [size](chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/size). kotlin indexOf indexOf ======= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [indexOf](index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.indexOf(element: T): Int ``` Returns first index of [element](index-of#kotlin.sequences%24indexOf(kotlin.sequences.Sequence((kotlin.sequences.indexOf.T)),%20kotlin.sequences.indexOf.T)/element), or -1 if the sequence does not contain element. The operation is *terminal*. kotlin associate associate ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <associate> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V> Sequence<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](associate#kotlin.sequences%24associate(kotlin.sequences.Sequence((kotlin.sequences.associate.T)),%20kotlin.Function1((kotlin.sequences.associate.T,%20kotlin.Pair((kotlin.sequences.associate.K,%20kotlin.sequences.associate.V)))))/transform) function applied to elements of the given sequence. If any of two pairs would have the same key the last one gets added to the map. The returned map preserves the entry iteration order of the original sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val names = listOf("Grace Hopper", "Jacob Bernoulli", "Johann Bernoulli") val byLastName = names.associate { it.split(" ").let { (firstName, lastName) -> lastName to firstName } } // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace, Bernoulli=Johann} //sampleEnd } ``` kotlin withIndex withIndex ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [withIndex](with-index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.withIndex(): Sequence<IndexedValue<T>> ``` Returns a sequence that wraps each element of the original sequence into an [IndexedValue](../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. The operation is *intermediate* and *stateless*. kotlin groupByTo groupByTo ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [groupByTo](group-by-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Sequence<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups elements of the original sequence by the key returned by the given [keySelector](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val byLength = words.groupBy { it.length } println(byLength.keys) // [1, 3, 2, 4] println(byLength.values) // [[a], [abc, def], [ab], [abcd]] val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } // same content as in byLength map, but the map is mutable println("mutableByLength == byLength is ${mutableByLength == byLength}") // true //sampleEnd } ``` **Return** The [destination](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)))/destination) map. The operation is *terminal*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Sequence<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` Groups values returned by the [valueTransform](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/valueTransform) function applied to each element of the original sequence by the key returned by the given [keySelector](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing") val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first }) println(namesByTeam) // {Marketing=[Alice, Carol], Sales=[Bob]} val mutableNamesByTeam = nameToTeam.groupByTo(HashMap(), { it.second }, { it.first }) // same content as in namesByTeam map, but the map is mutable println("mutableNamesByTeam == namesByTeam is ${mutableNamesByTeam == namesByTeam}") // true //sampleEnd } ``` **Return** The [destination](group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/destination) map. The operation is *terminal*. kotlin plus plus ==== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.plus(element: T): Sequence<T> ``` Returns a sequence containing all elements of the original sequence and then the given [element](plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.sequences.plus.T)/element). The operation is *intermediate* and *stateless*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.plus(     elements: Array<out T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.Array((kotlin.sequences.plus.T)))/elements) array. Note that the source sequence and the array being added are iterated only when an `iterator` is requested from the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. The operation is *intermediate* and *stateless*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.plus(     elements: Iterable<T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.collections.Iterable((kotlin.sequences.plus.T)))/elements) collection. Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. The operation is *intermediate* and *stateless*. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Sequence<T>.plus(     elements: Sequence<T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.sequences.Sequence((kotlin.sequences.plus.T)))/elements) sequence. Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. The operation is *intermediate* and *stateless*. kotlin mapNotNullTo mapNotNullTo ============ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [mapNotNullTo](map-not-null-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` Applies the given [transform](map-not-null-to#kotlin.sequences%24mapNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapNotNullTo.T)),%20kotlin.sequences.mapNotNullTo.C,%20kotlin.Function1((kotlin.sequences.mapNotNullTo.T,%20kotlin.sequences.mapNotNullTo.R?)))/transform) function to each element in the original sequence and appends only the non-null results to the given [destination](map-not-null-to#kotlin.sequences%24mapNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapNotNullTo.T)),%20kotlin.sequences.mapNotNullTo.C,%20kotlin.Function1((kotlin.sequences.mapNotNullTo.T,%20kotlin.sequences.mapNotNullTo.R?)))/destination). The operation is *terminal*.
programming_docs
kotlin filterNot filterNot ========= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterNot](filter-not) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.filterNot(     predicate: (T) -> Boolean ): Sequence<T> ``` Returns a sequence containing all elements not matching the given [predicate](filter-not#kotlin.sequences%24filterNot(kotlin.sequences.Sequence((kotlin.sequences.filterNot.T)),%20kotlin.Function1((kotlin.sequences.filterNot.T,%20kotlin.Boolean)))/predicate). The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = numbers.filter { it % 2 == 0 } val notMultiplesOf3 = numbers.filterNot { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` kotlin elementAtOrElse elementAtOrElse =============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [elementAtOrElse](element-at-or-else) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` Returns an element at the given [index](element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/defaultValue) function if the [index](element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/index) is out of bounds of this sequence. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrElse(0) { 42 }) // 1 println(list.elementAtOrElse(2) { 42 }) // 3 println(list.elementAtOrElse(3) { 42 }) // 42 val emptyList = emptyList<Int>() println(emptyList.elementAtOrElse(0) { "no int" }) // no int //sampleEnd } ``` kotlin runningReduceIndexed runningReduceIndexed ==================== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [runningReduceIndexed](running-reduce-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <S, T : S> Sequence<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): Sequence<S> ``` Returns a sequence containing successive accumulation values generated by applying [operation](running-reduce-indexed#kotlin.sequences%24runningReduceIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningReduceIndexed.S,%20kotlin.sequences.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with the first element of this sequence. Note that `acc` value passed to [operation](running-reduce-indexed#kotlin.sequences%24runningReduceIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningReduceIndexed.S,%20kotlin.sequences.runningReduceIndexed.T,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. The operation is *intermediate* and *stateless*. kotlin filterNotNull filterNotNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [filterNotNull](filter-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> Sequence<T?>.filterNotNull(): Sequence<T> ``` Returns a sequence containing all elements that are not `null`. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int?> = listOf(1, 2, null, 4) val nonNullNumbers = numbers.filterNotNull() println(nonNullNumbers) // [1, 2, 4] //sampleEnd } ``` kotlin minOfOrNull minOfOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [minOfOrNull](min-of-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T> Sequence<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` inline fun <T> Sequence<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.sequences%24minOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the sequence or `null` if there are no elements. If any of values produced by [selector](min-of-or-null#kotlin.sequences%24minOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.minOfOrNull.T,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. The operation is *terminal*. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <T, R : Comparable<R>> Sequence<T>.minOfOrNull(     selector: (T) -> R ): R? ``` Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.sequences%24minOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.minOfOrNull.T,%20kotlin.sequences.minOfOrNull.R)))/selector) function applied to each element in the sequence or `null` if there are no elements. The operation is *terminal*. kotlin sequenceOf sequenceOf ========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [sequenceOf](sequence-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> sequenceOf(vararg elements: T): Sequence<T> ``` Creates a sequence that returns the specified values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = sequenceOf("first", "second", "last") sequence.forEach(::println) //sampleEnd } ``` kotlin filter filter ====== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <filter> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.filter(     predicate: (T) -> Boolean ): Sequence<T> ``` Returns a sequence containing only elements matching the given [predicate](filter#kotlin.sequences%24filter(kotlin.sequences.Sequence((kotlin.sequences.filter.T)),%20kotlin.Function1((kotlin.sequences.filter.T,%20kotlin.Boolean)))/predicate). The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = numbers.filter { it % 2 == 0 } val notMultiplesOf3 = numbers.filterNot { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` kotlin associateWithTo associateWithTo =============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [associateWithTo](associate-with-to) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <K, V, M : MutableMap<in K, in V>> Sequence<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` Populates and returns the [destination](associate-with-to#kotlin.sequences%24associateWithTo(kotlin.sequences.Sequence((kotlin.sequences.associateWithTo.K)),%20kotlin.sequences.associateWithTo.M,%20kotlin.Function1((kotlin.sequences.associateWithTo.K,%20kotlin.sequences.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given sequence, where key is the element itself and value is provided by the [valueSelector](associate-with-to#kotlin.sequences%24associateWithTo(kotlin.sequences.Sequence((kotlin.sequences.associateWithTo.K)),%20kotlin.sequences.associateWithTo.M,%20kotlin.Function1((kotlin.sequences.associateWithTo.K,%20kotlin.sequences.associateWithTo.V)))/valueSelector) function applied to that key. If any two elements are equal, the last one overwrites the former value in the map. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) { override fun toString(): String = "$firstName $lastName" } val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Jacob", "Bernoulli")) val withLengthOfNames = mutableMapOf<Person, Int>() println("withLengthOfNames.isEmpty() is ${withLengthOfNames.isEmpty()}") // true scientists.associateWithTo(withLengthOfNames) { it.firstName.length + it.lastName.length } println("withLengthOfNames.isNotEmpty() is ${withLengthOfNames.isNotEmpty()}") // true // Jacob Bernoulli only occurs once in the map because only the last pair with the same key gets added println(withLengthOfNames) // {Grace Hopper=11, Jacob Bernoulli=14} //sampleEnd } ``` kotlin firstNotNullOf firstNotNullOf ============== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [firstNotNullOf](first-not-null-of) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <T, R : Any> Sequence<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` Returns the first non-null value produced by [transform](first-not-null-of#kotlin.sequences%24firstNotNullOf(kotlin.sequences.Sequence((kotlin.sequences.firstNotNullOf.T)),%20kotlin.Function1((kotlin.sequences.firstNotNullOf.T,%20kotlin.sequences.firstNotNullOf.R?)))/transform) function being applied to elements of this sequence in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` kotlin sortedDescending sortedDescending ================ [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [sortedDescending](sorted-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> Sequence<T>.sortedDescending(): Sequence<T> ``` Returns a sequence that yields elements of this sequence sorted descending according to their natural sort order. The sort is *stable*. It means that equal elements preserve their order relative to each other after sorting. The operation is *intermediate* and *stateful*. kotlin first first ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.first(): T ``` Returns the first element. The operation is *terminal*. Exceptions ---------- `NoSuchElementException` - if the sequence is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Sequence<T>.first(     predicate: (T) -> Boolean ): T ``` Returns the first element matching the given [predicate](first#kotlin.sequences%24first(kotlin.sequences.Sequence((kotlin.sequences.first.T)),%20kotlin.Function1((kotlin.sequences.first.T,%20kotlin.Boolean)))/predicate). Exceptions ---------- `NoSuchElementException` - if no such element is found. The operation is *terminal*. kotlin mapTo mapTo ===== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [mapTo](map-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` Applies the given [transform](map-to#kotlin.sequences%24mapTo(kotlin.sequences.Sequence((kotlin.sequences.mapTo.T)),%20kotlin.sequences.mapTo.C,%20kotlin.Function1((kotlin.sequences.mapTo.T,%20kotlin.sequences.mapTo.R)))/transform) function to each element of the original sequence and appends the results to the given [destination](map-to#kotlin.sequences%24mapTo(kotlin.sequences.Sequence((kotlin.sequences.mapTo.T)),%20kotlin.sequences.mapTo.C,%20kotlin.Function1((kotlin.sequences.mapTo.T,%20kotlin.sequences.mapTo.R)))/destination). The operation is *terminal*. kotlin zipWithNext zipWithNext =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [zipWithNext](zip-with-next) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T> Sequence<T>.zipWithNext(): Sequence<Pair<T, T>> ``` Returns a sequence of pairs of each two adjacent elements in this sequence. The returned sequence is empty if this sequence contains less than two elements. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val letters = ('a'..'f').toList() val pairs = letters.zipWithNext() println(letters) // [a, b, c, d, e, f] println(pairs) // [(a, b), (b, c), (c, d), (d, e), (e, f)] //sampleEnd } ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <T, R> Sequence<T>.zipWithNext(     transform: (a: T, b: T) -> R ): Sequence<R> ``` Returns a sequence containing the results of applying the given [transform](zip-with-next#kotlin.sequences%24zipWithNext(kotlin.sequences.Sequence((kotlin.sequences.zipWithNext.T)),%20kotlin.Function2((kotlin.sequences.zipWithNext.T,%20,%20kotlin.sequences.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this sequence. The returned sequence is empty if this sequence contains less than two elements. The operation is *intermediate* and *stateless*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val values = listOf(1, 4, 9, 16, 25, 36) val deltas = values.zipWithNext { a, b -> b - a } println(deltas) // [3, 5, 7, 9, 11] //sampleEnd } ``` kotlin associateTo associateTo =========== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / [associateTo](associate-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` Populates and returns the [destination](associate-to#kotlin.sequences%24associateTo(kotlin.sequences.Sequence((kotlin.sequences.associateTo.T)),%20kotlin.sequences.associateTo.M,%20kotlin.Function1((kotlin.sequences.associateTo.T,%20kotlin.Pair((kotlin.sequences.associateTo.K,%20kotlin.sequences.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](associate-to#kotlin.sequences%24associateTo(kotlin.sequences.Sequence((kotlin.sequences.associateTo.T)),%20kotlin.sequences.associateTo.M,%20kotlin.Function1((kotlin.sequences.associateTo.T,%20kotlin.Pair((kotlin.sequences.associateTo.K,%20kotlin.sequences.associateTo.V)))))/transform) function applied to each element of the given sequence. If any of two pairs would have the same key the last one gets added to the map. The operation is *terminal*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Person(val firstName: String, val lastName: String) val scientists = listOf(Person("Grace", "Hopper"), Person("Jacob", "Bernoulli"), Person("Johann", "Bernoulli")) val byLastName = mutableMapOf<String, String>() println("byLastName.isEmpty() is ${byLastName.isEmpty()}") // true scientists.associateTo(byLastName) { it.lastName to it.firstName } println("byLastName.isNotEmpty() is ${byLastName.isNotEmpty()}") // true // Jacob Bernoulli does not occur in the map because only the last pair with the same key gets added println(byLastName) // {Hopper=Grace, Bernoulli=Johann} //sampleEnd } ``` kotlin distinct distinct ======== [kotlin-stdlib](../../../../../index) / [kotlin.sequences](index) / <distinct> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Sequence<T>.distinct(): Sequence<T> ``` Returns a sequence containing only distinct elements from the given sequence. Among equal elements of the given sequence, only the first one will be present in the resulting sequence. The elements in the resulting sequence are in the same order as they were in the source sequence. The operation is *intermediate* and *stateful*. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('a', 'A', 'b', 'B', 'A', 'a') println(list.distinct()) // [a, A, b, B] println(list.distinctBy { it.uppercaseChar() }) // [a, b] //sampleEnd } ``` kotlin Sequence Sequence ======== [kotlin-stdlib](../../../../../../index) / [kotlin.sequences](../index) / [Sequence](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` interface Sequence<out T> ``` A sequence that returns values through its iterator. The values are evaluated lazily, and the sequence is potentially infinite. Sequences can be iterated multiple times, however some sequence implementations might constrain themselves to be iterated only once. That is mentioned specifically in their documentation (e.g. [generateSequence](../generate-sequence) overload). The latter sequences throw an exception on an attempt to iterate them the second time. Sequence operations, like [Sequence.map](../map), [Sequence.filter](../filter) etc, generally preserve that property of a sequence, and again it's documented for an operation if it doesn't. Parameters ---------- `T` - the type of elements in the sequence. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Returns an [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) that returns the values from the sequence. ``` abstract operator fun iterator(): Iterator<T> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../all) Returns `true` if all elements match the given [predicate](../all#kotlin.sequences%24all(kotlin.sequences.Sequence((kotlin.sequences.all.T)),%20kotlin.Function1((kotlin.sequences.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.all(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [any](../any) Returns `true` if sequence has at least one element. ``` fun <T> Sequence<T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../any#kotlin.sequences%24any(kotlin.sequences.Sequence((kotlin.sequences.any.T)),%20kotlin.Function1((kotlin.sequences.any.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original sequence returning its elements when being iterated. ``` fun <T> Sequence<T>.asIterable(): Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](../as-sequence) Returns this sequence as a [Sequence](index). ``` fun <T> Sequence<T>.asSequence(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associate](../associate) Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../associate#kotlin.sequences%24associate(kotlin.sequences.Sequence((kotlin.sequences.associate.T)),%20kotlin.Function1((kotlin.sequences.associate.T,%20kotlin.Pair((kotlin.sequences.associate.K,%20kotlin.sequences.associate.V)))))/transform) function applied to elements of the given sequence. ``` fun <T, K, V> Sequence<T>.associate(     transform: (T) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](../associate-by) Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the elements from the given sequence indexed by the key returned from [keySelector](../associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)))/keySelector) function applied to each element. ``` fun <T, K> Sequence<T>.associateBy(     keySelector: (T) -> K ): Map<K, T> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.V)))/valueTransform) and indexed by [keySelector](../associate-by#kotlin.sequences%24associateBy(kotlin.sequences.Sequence((kotlin.sequences.associateBy.T)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.K)),%20kotlin.Function1((kotlin.sequences.associateBy.T,%20kotlin.sequences.associateBy.V)))/keySelector) functions applied to elements of the given sequence. ``` fun <T, K, V> Sequence<T>.associateBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](../associate-by-to) Populates and returns the [destination](../associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)))/keySelector) function applied to each element of the given sequence and value is the element itself. ``` fun <T, K, M : MutableMap<in K, in T>> Sequence<T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](../associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../associate-by-to#kotlin.sequences%24associateByTo(kotlin.sequences.Sequence((kotlin.sequences.associateByTo.T)),%20kotlin.sequences.associateByTo.M,%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.K)),%20kotlin.Function1((kotlin.sequences.associateByTo.T,%20kotlin.sequences.associateByTo.V)))/valueTransform) function applied to elements of the given sequence. ``` fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](../associate-to) Populates and returns the [destination](../associate-to#kotlin.sequences%24associateTo(kotlin.sequences.Sequence((kotlin.sequences.associateTo.T)),%20kotlin.sequences.associateTo.M,%20kotlin.Function1((kotlin.sequences.associateTo.T,%20kotlin.Pair((kotlin.sequences.associateTo.K,%20kotlin.sequences.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](../associate-to#kotlin.sequences%24associateTo(kotlin.sequences.Sequence((kotlin.sequences.associateTo.T)),%20kotlin.sequences.associateTo.M,%20kotlin.Function1((kotlin.sequences.associateTo.T,%20kotlin.Pair((kotlin.sequences.associateTo.K,%20kotlin.sequences.associateTo.V)))))/transform) function applied to each element of the given sequence. ``` fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](../associate-with) Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) where keys are elements from the given sequence and values are produced by the [valueSelector](../associate-with#kotlin.sequences%24associateWith(kotlin.sequences.Sequence((kotlin.sequences.associateWith.K)),%20kotlin.Function1((kotlin.sequences.associateWith.K,%20kotlin.sequences.associateWith.V)))/valueSelector) function applied to each element. ``` fun <K, V> Sequence<K>.associateWith(     valueSelector: (K) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](../associate-with-to) Populates and returns the [destination](../associate-with-to#kotlin.sequences%24associateWithTo(kotlin.sequences.Sequence((kotlin.sequences.associateWithTo.K)),%20kotlin.sequences.associateWithTo.M,%20kotlin.Function1((kotlin.sequences.associateWithTo.K,%20kotlin.sequences.associateWithTo.V)))/destination) mutable map with key-value pairs for each element of the given sequence, where key is the element itself and value is provided by the [valueSelector](../associate-with-to#kotlin.sequences%24associateWithTo(kotlin.sequences.Sequence((kotlin.sequences.associateWithTo.K)),%20kotlin.sequences.associateWithTo.M,%20kotlin.Function1((kotlin.sequences.associateWithTo.K,%20kotlin.sequences.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <K, V, M : MutableMap<in K, in V>> Sequence<K>.associateWithTo(     destination: M,     valueSelector: (K) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [average](../average) Returns an average value of elements in the sequence. ``` fun Sequence<Byte>.average(): Double ``` ``` fun Sequence<Short>.average(): Double ``` ``` fun Sequence<Int>.average(): Double ``` ``` fun Sequence<Long>.average(): Double ``` ``` fun Sequence<Float>.average(): Double ``` ``` fun Sequence<Double>.average(): Double ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunked](../chunked) Splits this sequence into a sequence of lists each not exceeding the given [size](../chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int)/size). ``` fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> ``` Splits this sequence into several lists each not exceeding the given [size](../chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/size) and applies the given [transform](../chunked#kotlin.sequences%24chunked(kotlin.sequences.Sequence((kotlin.sequences.chunked.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.chunked.T)),%20kotlin.sequences.chunked.R)))/transform) function to an each. ``` fun <T, R> Sequence<T>.chunked(     size: Int,     transform: (List<T>) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [constrainOnce](../constrain-once) Returns a wrapper sequence that provides values of this sequence, but ensures it can be iterated only one time. ``` fun <T> Sequence<T>.constrainOnce(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Returns `true` if [element](../contains#kotlin.sequences%24contains(kotlin.sequences.Sequence((kotlin.sequences.contains.T)),%20kotlin.sequences.contains.T)/element) is found in the sequence. ``` operator fun <T> Sequence<T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../count) Returns the number of elements in this sequence. ``` fun <T> Sequence<T>.count(): Int ``` Returns the number of elements matching the given [predicate](../count#kotlin.sequences%24count(kotlin.sequences.Sequence((kotlin.sequences.count.T)),%20kotlin.Function1((kotlin.sequences.count.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.count(predicate: (T) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinct](../distinct) Returns a sequence containing only distinct elements from the given sequence. ``` fun <T> Sequence<T>.distinct(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [distinctBy](../distinct-by) Returns a sequence containing only elements from the given sequence having distinct keys returned by the given [selector](../distinct-by#kotlin.sequences%24distinctBy(kotlin.sequences.Sequence((kotlin.sequences.distinctBy.T)),%20kotlin.Function1((kotlin.sequences.distinctBy.T,%20kotlin.sequences.distinctBy.K)))/selector) function. ``` fun <T, K> Sequence<T>.distinctBy(     selector: (T) -> K ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../drop) Returns a sequence containing all elements except first [n](../drop#kotlin.sequences%24drop(kotlin.sequences.Sequence((kotlin.sequences.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Sequence<T>.drop(n: Int): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../drop-while) Returns a sequence containing all elements except first elements that satisfy the given [predicate](../drop-while#kotlin.sequences%24dropWhile(kotlin.sequences.Sequence((kotlin.sequences.dropWhile.T)),%20kotlin.Function1((kotlin.sequences.dropWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.dropWhile(     predicate: (T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](../element-at) Returns an element at the given [index](../element-at#kotlin.sequences%24elementAt(kotlin.sequences.Sequence((kotlin.sequences.elementAt.T)),%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](../element-at#kotlin.sequences%24elementAt(kotlin.sequences.Sequence((kotlin.sequences.elementAt.T)),%20kotlin.Int)/index) is out of bounds of this sequence. ``` fun <T> Sequence<T>.elementAt(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../element-at-or-else) Returns an element at the given [index](../element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/index) or the result of calling the [defaultValue](../element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/defaultValue) function if the [index](../element-at-or-else#kotlin.sequences%24elementAtOrElse(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrElse.T)),%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.sequences.elementAtOrElse.T)))/index) is out of bounds of this sequence. ``` fun <T> Sequence<T>.elementAtOrElse(     index: Int,     defaultValue: (Int) -> T ): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../element-at-or-null) Returns an element at the given [index](../element-at-or-null#kotlin.sequences%24elementAtOrNull(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../element-at-or-null#kotlin.sequences%24elementAtOrNull(kotlin.sequences.Sequence((kotlin.sequences.elementAtOrNull.T)),%20kotlin.Int)/index) is out of bounds of this sequence. ``` fun <T> Sequence<T>.elementAtOrNull(index: Int): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../filter) Returns a sequence containing only elements matching the given [predicate](../filter#kotlin.sequences%24filter(kotlin.sequences.Sequence((kotlin.sequences.filter.T)),%20kotlin.Function1((kotlin.sequences.filter.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.filter(     predicate: (T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../filter-indexed) Returns a sequence containing only elements matching the given [predicate](../filter-indexed#kotlin.sequences%24filterIndexed(kotlin.sequences.Sequence((kotlin.sequences.filterIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexed.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.filterIndexed(     predicate: (index: Int, T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../filter-indexed-to) Appends all elements matching the given [predicate](../filter-indexed-to#kotlin.sequences%24filterIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.filterIndexedTo.T)),%20kotlin.sequences.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexedTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-indexed-to#kotlin.sequences%24filterIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.filterIndexedTo.T)),%20kotlin.sequences.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.filterIndexedTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(     destination: C,     predicate: (index: Int, T) -> Boolean ): C ``` #### [filterIsInstance](../filter-is-instance) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns a sequence containing all elements that are instances of specified type parameter R. ``` fun <R> Sequence<*>.filterIsInstance(): Sequence<R> ``` **Platform and version requirements:** JVM (1.0) Returns a sequence containing all elements that are instances of specified class. ``` fun <R> Sequence<*>.filterIsInstance(     klass: Class<R> ): Sequence<R> ``` #### [filterIsInstanceTo](../filter-is-instance-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Appends all elements that are instances of specified type parameter R to the given [destination](../filter-is-instance-to#kotlin.sequences%24filterIsInstanceTo(kotlin.sequences.Sequence((kotlin.Any?)),%20kotlin.sequences.filterIsInstanceTo.C)/destination). ``` fun <R, C : MutableCollection<in R>> Sequence<*>.filterIsInstanceTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../filter-is-instance-to#kotlin.sequences%24filterIsInstanceTo(kotlin.sequences.Sequence((kotlin.Any?)),%20kotlin.sequences.filterIsInstanceTo.C,%20java.lang.Class((kotlin.sequences.filterIsInstanceTo.R)))/destination). ``` fun <C : MutableCollection<in R>, R> Sequence<*>.filterIsInstanceTo(     destination: C,     klass: Class<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](../filter-not) Returns a sequence containing all elements not matching the given [predicate](../filter-not#kotlin.sequences%24filterNot(kotlin.sequences.Sequence((kotlin.sequences.filterNot.T)),%20kotlin.Function1((kotlin.sequences.filterNot.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.filterNot(     predicate: (T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNull](../filter-not-null) Returns a sequence containing all elements that are not `null`. ``` fun <T : Any> Sequence<T?>.filterNotNull(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotNullTo](../filter-not-null-to) Appends all elements that are not `null` to the given [destination](../filter-not-null-to#kotlin.sequences%24filterNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotNullTo.T?)),%20kotlin.sequences.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Sequence<T?>.filterNotNullTo(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../filter-not-to) Appends all elements not matching the given [predicate](../filter-not-to#kotlin.sequences%24filterNotTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotTo.T)),%20kotlin.sequences.filterNotTo.C,%20kotlin.Function1((kotlin.sequences.filterNotTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-not-to#kotlin.sequences%24filterNotTo(kotlin.sequences.Sequence((kotlin.sequences.filterNotTo.T)),%20kotlin.sequences.filterNotTo.C,%20kotlin.Function1((kotlin.sequences.filterNotTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Sequence<T>.filterNotTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](../filter-to) Appends all elements matching the given [predicate](../filter-to#kotlin.sequences%24filterTo(kotlin.sequences.Sequence((kotlin.sequences.filterTo.T)),%20kotlin.sequences.filterTo.C,%20kotlin.Function1((kotlin.sequences.filterTo.T,%20kotlin.Boolean)))/predicate) to the given [destination](../filter-to#kotlin.sequences%24filterTo(kotlin.sequences.Sequence((kotlin.sequences.filterTo.T)),%20kotlin.sequences.filterTo.C,%20kotlin.Function1((kotlin.sequences.filterTo.T,%20kotlin.Boolean)))/destination). ``` fun <T, C : MutableCollection<in T>> Sequence<T>.filterTo(     destination: C,     predicate: (T) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [find](../find) Returns the first element matching the given [predicate](../find#kotlin.sequences%24find(kotlin.sequences.Sequence((kotlin.sequences.find.T)),%20kotlin.Function1((kotlin.sequences.find.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Sequence<T>.find(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](../find-last) Returns the last element matching the given [predicate](../find-last#kotlin.sequences%24findLast(kotlin.sequences.Sequence((kotlin.sequences.findLast.T)),%20kotlin.Function1((kotlin.sequences.findLast.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Sequence<T>.findLast(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../first) Returns the first element. ``` fun <T> Sequence<T>.first(): T ``` Returns the first element matching the given [predicate](../first#kotlin.sequences%24first(kotlin.sequences.Sequence((kotlin.sequences.first.T)),%20kotlin.Function1((kotlin.sequences.first.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.first(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](../first-not-null-of) Returns the first non-null value produced by [transform](../first-not-null-of#kotlin.sequences%24firstNotNullOf(kotlin.sequences.Sequence((kotlin.sequences.firstNotNullOf.T)),%20kotlin.Function1((kotlin.sequences.firstNotNullOf.T,%20kotlin.sequences.firstNotNullOf.R?)))/transform) function being applied to elements of this sequence in iteration order, or throws [NoSuchElementException](../../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <T, R : Any> Sequence<T>.firstNotNullOf(     transform: (T) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](../first-not-null-of-or-null) Returns the first non-null value produced by [transform](../first-not-null-of-or-null#kotlin.sequences%24firstNotNullOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.firstNotNullOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.firstNotNullOfOrNull.T,%20kotlin.sequences.firstNotNullOfOrNull.R?)))/transform) function being applied to elements of this sequence in iteration order, or `null` if no non-null value was produced. ``` fun <T, R : Any> Sequence<T>.firstNotNullOfOrNull(     transform: (T) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the sequence is empty. ``` fun <T> Sequence<T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../first-or-null#kotlin.sequences%24firstOrNull(kotlin.sequences.Sequence((kotlin.sequences.firstOrNull.T)),%20kotlin.Function1((kotlin.sequences.firstOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun <T> Sequence<T>.firstOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](../flat-map) Returns a single sequence of all elements from results of [transform](../flat-map#kotlin.sequences%24flatMap(kotlin.sequences.Sequence((kotlin.sequences.flatMap.T)),%20kotlin.Function1((kotlin.sequences.flatMap.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMap.R)))))/transform) function being invoked on each element of original sequence. ``` fun <T, R> Sequence<T>.flatMap(     transform: (T) -> Iterable<R> ): Sequence<R> ``` ``` fun <T, R> Sequence<T>.flatMap(     transform: (T) -> Sequence<R> ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](../flat-map-indexed) Returns a single sequence of all elements yielded from results of [transform](../flat-map-indexed#kotlin.sequences%24flatMapIndexed(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexed.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original sequence. ``` fun <T, R> Sequence<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<R> ): Sequence<R> ``` ``` fun <T, R> Sequence<T>.flatMapIndexed(     transform: (index: Int, T) -> Sequence<R> ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](../flat-map-indexed-to) Appends all elements yielded from results of [transform](../flat-map-indexed-to#kotlin.sequences%24flatMapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexedTo.T)),%20kotlin.sequences.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexedTo.R)))))/transform) function being invoked on each element and its index in the original sequence, to the given [destination](../flat-map-indexed-to#kotlin.sequences%24flatMapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapIndexedTo.T)),%20kotlin.sequences.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.flatMapIndexedTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapIndexedTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](../flat-map-to) Appends all elements yielded from results of [transform](../flat-map-to#kotlin.sequences%24flatMapTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapTo.T)),%20kotlin.sequences.flatMapTo.C,%20kotlin.Function1((kotlin.sequences.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapTo.R)))))/transform) function being invoked on each element of original sequence, to the given [destination](../flat-map-to#kotlin.sequences%24flatMapTo(kotlin.sequences.Sequence((kotlin.sequences.flatMapTo.T)),%20kotlin.sequences.flatMapTo.C,%20kotlin.Function1((kotlin.sequences.flatMapTo.T,%20kotlin.collections.Iterable((kotlin.sequences.flatMapTo.R)))))/destination). ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<R> ): C ``` ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(     destination: C,     transform: (T) -> Sequence<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatten](../flatten) Returns a sequence of all elements from all sequences in this sequence. ``` fun <T> Sequence<Sequence<T>>.flatten(): Sequence<T> ``` Returns a sequence of all elements from all iterables in this sequence. ``` fun <T> Sequence<Iterable<T>>.flatten(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fold](../fold) Accumulates value starting with [initial](../fold#kotlin.sequences%24fold(kotlin.sequences.Sequence((kotlin.sequences.fold.T)),%20kotlin.sequences.fold.R,%20kotlin.Function2((kotlin.sequences.fold.R,%20kotlin.sequences.fold.T,%20)))/initial) value and applying [operation](../fold#kotlin.sequences%24fold(kotlin.sequences.Sequence((kotlin.sequences.fold.T)),%20kotlin.sequences.fold.R,%20kotlin.Function2((kotlin.sequences.fold.R,%20kotlin.sequences.fold.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <T, R> Sequence<T>.fold(     initial: R,     operation: (acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](../fold-indexed) Accumulates value starting with [initial](../fold-indexed#kotlin.sequences%24foldIndexed(kotlin.sequences.Sequence((kotlin.sequences.foldIndexed.T)),%20kotlin.sequences.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.foldIndexed.R,%20kotlin.sequences.foldIndexed.T,%20)))/initial) value and applying [operation](../fold-indexed#kotlin.sequences%24foldIndexed(kotlin.sequences.Sequence((kotlin.sequences.foldIndexed.T)),%20kotlin.sequences.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.foldIndexed.R,%20kotlin.sequences.foldIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. ``` fun <T, R> Sequence<T>.foldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](../for-each) Performs the given [action](../for-each#kotlin.sequences%24forEach(kotlin.sequences.Sequence((kotlin.sequences.forEach.T)),%20kotlin.Function1((kotlin.sequences.forEach.T,%20kotlin.Unit)))/action) on each element. ``` fun <T> Sequence<T>.forEach(action: (T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](../for-each-indexed) Performs the given [action](../for-each-indexed#kotlin.sequences%24forEachIndexed(kotlin.sequences.Sequence((kotlin.sequences.forEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.forEachIndexed.T,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun <T> Sequence<T>.forEachIndexed(     action: (index: Int, T) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](../group-by) Groups elements of the original sequence by the key returned by the given [keySelector](../group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)))/keySelector) function applied to each element and returns a map where each group key is associated with a list of corresponding elements. ``` fun <T, K> Sequence<T>.groupBy(     keySelector: (T) -> K ): Map<K, List<T>> ``` Groups values returned by the [valueTransform](../group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.V)))/valueTransform) function applied to each element of the original sequence by the key returned by the given [keySelector](../group-by#kotlin.sequences%24groupBy(kotlin.sequences.Sequence((kotlin.sequences.groupBy.T)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.K)),%20kotlin.Function1((kotlin.sequences.groupBy.T,%20kotlin.sequences.groupBy.V)))/keySelector) function applied to the element and returns a map where each group key is associated with a list of corresponding values. ``` fun <T, K, V> Sequence<T>.groupBy(     keySelector: (T) -> K,     valueTransform: (T) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](../group-by-to) Groups elements of the original sequence by the key returned by the given [keySelector](../group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <T, K, M : MutableMap<in K, MutableList<T>>> Sequence<T>.groupByTo(     destination: M,     keySelector: (T) -> K ): M ``` Groups values returned by the [valueTransform](../group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/valueTransform) function applied to each element of the original sequence by the key returned by the given [keySelector](../group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../group-by-to#kotlin.sequences%24groupByTo(kotlin.sequences.Sequence((kotlin.sequences.groupByTo.T)),%20kotlin.sequences.groupByTo.M,%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.K)),%20kotlin.Function1((kotlin.sequences.groupByTo.T,%20kotlin.sequences.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Sequence<T>.groupByTo(     destination: M,     keySelector: (T) -> K,     valueTransform: (T) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](../grouping-by) Creates a [Grouping](../../kotlin.collections/-grouping/index) source from a sequence to be used later with one of group-and-fold operations using the specified [keySelector](../grouping-by#kotlin.sequences%24groupingBy(kotlin.sequences.Sequence((kotlin.sequences.groupingBy.T)),%20kotlin.Function1((kotlin.sequences.groupingBy.T,%20kotlin.sequences.groupingBy.K)))/keySelector) function to extract a key from each element. ``` fun <T, K> Sequence<T>.groupingBy(     keySelector: (T) -> K ): Grouping<T, K> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](../if-empty) Returns a sequence that iterates through the elements either of this sequence or, if this sequence turns out to be empty, of the sequence returned by [defaultValue](../if-empty#kotlin.sequences%24ifEmpty(kotlin.sequences.Sequence((kotlin.sequences.ifEmpty.T)),%20kotlin.Function0((kotlin.sequences.Sequence((kotlin.sequences.ifEmpty.T)))))/defaultValue) function. ``` fun <T> Sequence<T>.ifEmpty(     defaultValue: () -> Sequence<T> ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../index-of) Returns first index of [element](../index-of#kotlin.sequences%24indexOf(kotlin.sequences.Sequence((kotlin.sequences.indexOf.T)),%20kotlin.sequences.indexOf.T)/element), or -1 if the sequence does not contain element. ``` fun <T> Sequence<T>.indexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](../index-of-first) Returns index of the first element matching the given [predicate](../index-of-first#kotlin.sequences%24indexOfFirst(kotlin.sequences.Sequence((kotlin.sequences.indexOfFirst.T)),%20kotlin.Function1((kotlin.sequences.indexOfFirst.T,%20kotlin.Boolean)))/predicate), or -1 if the sequence does not contain such element. ``` fun <T> Sequence<T>.indexOfFirst(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](../index-of-last) Returns index of the last element matching the given [predicate](../index-of-last#kotlin.sequences%24indexOfLast(kotlin.sequences.Sequence((kotlin.sequences.indexOfLast.T)),%20kotlin.Function1((kotlin.sequences.indexOfLast.T,%20kotlin.Boolean)))/predicate), or -1 if the sequence does not contain such element. ``` fun <T> Sequence<T>.indexOfLast(     predicate: (T) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinTo](../join-to) Appends the string from all the elements separated using [separator](../join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to#kotlin.sequences%24joinTo(kotlin.sequences.Sequence((kotlin.sequences.joinTo.T)),%20kotlin.sequences.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinTo.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T, A : Appendable> Sequence<T>.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [joinToString](../join-to-string) Creates a string from all the elements separated using [separator](../join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/separator) and using the given [prefix](../join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/prefix) and [postfix](../join-to-string#kotlin.sequences%24joinToString(kotlin.sequences.Sequence((kotlin.sequences.joinToString.T)),%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.sequences.joinToString.T,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <T> Sequence<T>.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((T) -> CharSequence)? = null ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../last) Returns the last element. ``` fun <T> Sequence<T>.last(): T ``` Returns the last element matching the given [predicate](../last#kotlin.sequences%24last(kotlin.sequences.Sequence((kotlin.sequences.last.T)),%20kotlin.Function1((kotlin.sequences.last.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](../last-index-of) Returns last index of [element](../last-index-of#kotlin.sequences%24lastIndexOf(kotlin.sequences.Sequence((kotlin.sequences.lastIndexOf.T)),%20kotlin.sequences.lastIndexOf.T)/element), or -1 if the sequence does not contain element. ``` fun <T> Sequence<T>.lastIndexOf(element: T): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the sequence is empty. ``` fun <T> Sequence<T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../last-or-null#kotlin.sequences%24lastOrNull(kotlin.sequences.Sequence((kotlin.sequences.lastOrNull.T)),%20kotlin.Function1((kotlin.sequences.lastOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun <T> Sequence<T>.lastOrNull(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../map) Returns a sequence containing the results of applying the given [transform](../map#kotlin.sequences%24map(kotlin.sequences.Sequence((kotlin.sequences.map.T)),%20kotlin.Function1((kotlin.sequences.map.T,%20kotlin.sequences.map.R)))/transform) function to each element in the original sequence. ``` fun <T, R> Sequence<T>.map(transform: (T) -> R): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](../map-indexed) Returns a sequence containing the results of applying the given [transform](../map-indexed#kotlin.sequences%24mapIndexed(kotlin.sequences.Sequence((kotlin.sequences.mapIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexed.T,%20kotlin.sequences.mapIndexed.R)))/transform) function to each element and its index in the original sequence. ``` fun <T, R> Sequence<T>.mapIndexed(     transform: (index: Int, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](../map-indexed-not-null) Returns a sequence containing only the non-null results of applying the given [transform](../map-indexed-not-null#kotlin.sequences%24mapIndexedNotNull(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNull.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNull.T,%20kotlin.sequences.mapIndexedNotNull.R?)))/transform) function to each element and its index in the original sequence. ``` fun <T, R : Any> Sequence<T>.mapIndexedNotNull(     transform: (index: Int, T) -> R? ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](../map-indexed-not-null-to) Applies the given [transform](../map-indexed-not-null-to#kotlin.sequences%24mapIndexedNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNullTo.T)),%20kotlin.sequences.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNullTo.T,%20kotlin.sequences.mapIndexedNotNullTo.R?)))/transform) function to each element and its index in the original sequence and appends only the non-null results to the given [destination](../map-indexed-not-null-to#kotlin.sequences%24mapIndexedNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedNotNullTo.T)),%20kotlin.sequences.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedNotNullTo.T,%20kotlin.sequences.mapIndexedNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](../map-indexed-to) Applies the given [transform](../map-indexed-to#kotlin.sequences%24mapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedTo.T)),%20kotlin.sequences.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedTo.T,%20kotlin.sequences.mapIndexedTo.R)))/transform) function to each element and its index in the original sequence and appends the results to the given [destination](../map-indexed-to#kotlin.sequences%24mapIndexedTo(kotlin.sequences.Sequence((kotlin.sequences.mapIndexedTo.T)),%20kotlin.sequences.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.mapIndexedTo.T,%20kotlin.sequences.mapIndexedTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(     destination: C,     transform: (index: Int, T) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](../map-not-null) Returns a sequence containing only the non-null results of applying the given [transform](../map-not-null#kotlin.sequences%24mapNotNull(kotlin.sequences.Sequence((kotlin.sequences.mapNotNull.T)),%20kotlin.Function1((kotlin.sequences.mapNotNull.T,%20kotlin.sequences.mapNotNull.R?)))/transform) function to each element in the original sequence. ``` fun <T, R : Any> Sequence<T>.mapNotNull(     transform: (T) -> R? ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](../map-not-null-to) Applies the given [transform](../map-not-null-to#kotlin.sequences%24mapNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapNotNullTo.T)),%20kotlin.sequences.mapNotNullTo.C,%20kotlin.Function1((kotlin.sequences.mapNotNullTo.T,%20kotlin.sequences.mapNotNullTo.R?)))/transform) function to each element in the original sequence and appends only the non-null results to the given [destination](../map-not-null-to#kotlin.sequences%24mapNotNullTo(kotlin.sequences.Sequence((kotlin.sequences.mapNotNullTo.T)),%20kotlin.sequences.mapNotNullTo.C,%20kotlin.Function1((kotlin.sequences.mapNotNullTo.T,%20kotlin.sequences.mapNotNullTo.R?)))/destination). ``` fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapNotNullTo(     destination: C,     transform: (T) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](../map-to) Applies the given [transform](../map-to#kotlin.sequences%24mapTo(kotlin.sequences.Sequence((kotlin.sequences.mapTo.T)),%20kotlin.sequences.mapTo.C,%20kotlin.Function1((kotlin.sequences.mapTo.T,%20kotlin.sequences.mapTo.R)))/transform) function to each element of the original sequence and appends the results to the given [destination](../map-to#kotlin.sequences%24mapTo(kotlin.sequences.Sequence((kotlin.sequences.mapTo.T)),%20kotlin.sequences.mapTo.C,%20kotlin.Function1((kotlin.sequences.mapTo.T,%20kotlin.sequences.mapTo.R)))/destination). ``` fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapTo(     destination: C,     transform: (T) -> R ): C ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../max-by-or-null) Returns the first element yielding the largest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Sequence<T>.maxByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](../max-of) Returns the largest value among all values produced by [selector](../max-of#kotlin.sequences%24maxOf(kotlin.sequences.Sequence((kotlin.sequences.maxOf.T)),%20kotlin.Function1((kotlin.sequences.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. ``` fun <T> Sequence<T>.maxOf(selector: (T) -> Double): Double ``` ``` fun <T> Sequence<T>.maxOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Sequence<T>.maxOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](../max-of-or-null) Returns the largest value among all values produced by [selector](../max-of-or-null#kotlin.sequences%24maxOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.maxOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the sequence or `null` if there are no elements. ``` fun <T> Sequence<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Sequence<T>.maxOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Sequence<T>.maxOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](../max-of-with) Returns the largest value according to the provided [comparator](../max-of-with#kotlin.sequences%24maxOfWith(kotlin.sequences.Sequence((kotlin.sequences.maxOfWith.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWith.R)),%20kotlin.Function1((kotlin.sequences.maxOfWith.T,%20kotlin.sequences.maxOfWith.R)))/comparator) among all values produced by [selector](../max-of-with#kotlin.sequences%24maxOfWith(kotlin.sequences.Sequence((kotlin.sequences.maxOfWith.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWith.R)),%20kotlin.Function1((kotlin.sequences.maxOfWith.T,%20kotlin.sequences.maxOfWith.R)))/selector) function applied to each element in the sequence. ``` fun <T, R> Sequence<T>.maxOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](../max-of-with-or-null) Returns the largest value according to the provided [comparator](../max-of-with-or-null#kotlin.sequences%24maxOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.maxOfWithOrNull.T,%20kotlin.sequences.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../max-of-with-or-null#kotlin.sequences%24maxOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.maxOfWithOrNull.T,%20kotlin.sequences.maxOfWithOrNull.R)))/selector) function applied to each element in the sequence or `null` if there are no elements. ``` fun <T, R> Sequence<T>.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOrNull](../max-or-null) Returns the largest element or `null` if there are no elements. ``` fun Sequence<Double>.maxOrNull(): Double? ``` ``` fun Sequence<Float>.maxOrNull(): Float? ``` ``` fun <T : Comparable<T>> Sequence<T>.maxOrNull(): T? ``` #### [maxWith](../max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the largest value according to the provided [comparator](../max-with#kotlin.sequences%24maxWith(kotlin.sequences.Sequence((kotlin.sequences.maxWith.T)),%20kotlin.Comparator((kotlin.sequences.maxWith.T)))/comparator). ``` fun <T> Sequence<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Sequence<T>.maxWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](../max-with-or-null) Returns the first element having the largest value according to the provided [comparator](../max-with-or-null#kotlin.sequences%24maxWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.maxWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.maxWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Sequence<T>.maxWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../min-by-or-null) Returns the first element yielding the smallest value of the given function or `null` if there are no elements. ``` fun <T, R : Comparable<R>> Sequence<T>.minByOrNull(     selector: (T) -> R ): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](../min-of) Returns the smallest value among all values produced by [selector](../min-of#kotlin.sequences%24minOf(kotlin.sequences.Sequence((kotlin.sequences.minOf.T)),%20kotlin.Function1((kotlin.sequences.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. ``` fun <T> Sequence<T>.minOf(selector: (T) -> Double): Double ``` ``` fun <T> Sequence<T>.minOf(selector: (T) -> Float): Float ``` ``` fun <T, R : Comparable<R>> Sequence<T>.minOf(     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](../min-of-or-null) Returns the smallest value among all values produced by [selector](../min-of-or-null#kotlin.sequences%24minOfOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfOrNull.T)),%20kotlin.Function1((kotlin.sequences.minOfOrNull.T,%20kotlin.Double)))/selector) function applied to each element in the sequence or `null` if there are no elements. ``` fun <T> Sequence<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` ``` fun <T> Sequence<T>.minOfOrNull(     selector: (T) -> Float ): Float? ``` ``` fun <T, R : Comparable<R>> Sequence<T>.minOfOrNull(     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](../min-of-with) Returns the smallest value according to the provided [comparator](../min-of-with#kotlin.sequences%24minOfWith(kotlin.sequences.Sequence((kotlin.sequences.minOfWith.T)),%20kotlin.Comparator((kotlin.sequences.minOfWith.R)),%20kotlin.Function1((kotlin.sequences.minOfWith.T,%20kotlin.sequences.minOfWith.R)))/comparator) among all values produced by [selector](../min-of-with#kotlin.sequences%24minOfWith(kotlin.sequences.Sequence((kotlin.sequences.minOfWith.T)),%20kotlin.Comparator((kotlin.sequences.minOfWith.R)),%20kotlin.Function1((kotlin.sequences.minOfWith.T,%20kotlin.sequences.minOfWith.R)))/selector) function applied to each element in the sequence. ``` fun <T, R> Sequence<T>.minOfWith(     comparator: Comparator<in R>,     selector: (T) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](../min-of-with-or-null) Returns the smallest value according to the provided [comparator](../min-of-with-or-null#kotlin.sequences%24minOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.minOfWithOrNull.T,%20kotlin.sequences.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../min-of-with-or-null#kotlin.sequences%24minOfWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minOfWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.sequences.minOfWithOrNull.T,%20kotlin.sequences.minOfWithOrNull.R)))/selector) function applied to each element in the sequence or `null` if there are no elements. ``` fun <T, R> Sequence<T>.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (T) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOrNull](../min-or-null) Returns the smallest element or `null` if there are no elements. ``` fun Sequence<Double>.minOrNull(): Double? ``` ``` fun Sequence<Float>.minOrNull(): Float? ``` ``` fun <T : Comparable<T>> Sequence<T>.minOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minus](../minus) Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element](../minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.sequences.minus.T)/element). ``` operator fun <T> Sequence<T>.minus(element: T): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](../minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.Array((kotlin.sequences.minus.T)))/elements) array. ``` operator fun <T> Sequence<T>.minus(     elements: Array<out T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](../minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.collections.Iterable((kotlin.sequences.minus.T)))/elements) collection. ``` operator fun <T> Sequence<T>.minus(     elements: Iterable<T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence except the elements contained in the given [elements](../minus#kotlin.sequences%24minus(kotlin.sequences.Sequence((kotlin.sequences.minus.T)),%20kotlin.sequences.Sequence((kotlin.sequences.minus.T)))/elements) sequence. ``` operator fun <T> Sequence<T>.minus(     elements: Sequence<T> ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minusElement](../minus-element) Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element](../minus-element#kotlin.sequences%24minusElement(kotlin.sequences.Sequence((kotlin.sequences.minusElement.T)),%20kotlin.sequences.minusElement.T)/element). ``` fun <T> Sequence<T>.minusElement(element: T): Sequence<T> ``` #### [minWith](../min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first element having the smallest value according to the provided [comparator](../min-with#kotlin.sequences%24minWith(kotlin.sequences.Sequence((kotlin.sequences.minWith.T)),%20kotlin.Comparator((kotlin.sequences.minWith.T)))/comparator). ``` fun <T> Sequence<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Sequence<T>.minWith(comparator: Comparator<in T>): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](../min-with-or-null) Returns the first element having the smallest value according to the provided [comparator](../min-with-or-null#kotlin.sequences%24minWithOrNull(kotlin.sequences.Sequence((kotlin.sequences.minWithOrNull.T)),%20kotlin.Comparator((kotlin.sequences.minWithOrNull.T)))/comparator) or `null` if there are no elements. ``` fun <T> Sequence<T>.minWithOrNull(     comparator: Comparator<in T> ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [none](../none) Returns `true` if the sequence has no elements. ``` fun <T> Sequence<T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../none#kotlin.sequences%24none(kotlin.sequences.Sequence((kotlin.sequences.none.T)),%20kotlin.Function1((kotlin.sequences.none.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.none(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](../on-each) Returns a sequence which performs the given [action](../on-each#kotlin.sequences%24onEach(kotlin.sequences.Sequence((kotlin.sequences.onEach.T)),%20kotlin.Function1((kotlin.sequences.onEach.T,%20kotlin.Unit)))/action) on each element of the original sequence as they pass through it. ``` fun <T> Sequence<T>.onEach(action: (T) -> Unit): Sequence<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](../on-each-indexed) Returns a sequence which performs the given [action](../on-each-indexed#kotlin.sequences%24onEachIndexed(kotlin.sequences.Sequence((kotlin.sequences.onEachIndexed.T)),%20kotlin.Function2((kotlin.Int,%20kotlin.sequences.onEachIndexed.T,%20kotlin.Unit)))/action) on each element of the original sequence as they pass through it. ``` fun <T> Sequence<T>.onEachIndexed(     action: (index: Int, T) -> Unit ): Sequence<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [orEmpty](../or-empty) Returns this sequence if it's not `null` and the empty sequence otherwise. ``` fun <T> Sequence<T>?.orEmpty(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../partition) Splits the original sequence into pair of lists, where *first* list contains elements for which [predicate](../partition#kotlin.sequences%24partition(kotlin.sequences.Sequence((kotlin.sequences.partition.T)),%20kotlin.Function1((kotlin.sequences.partition.T,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../partition#kotlin.sequences%24partition(kotlin.sequences.Sequence((kotlin.sequences.partition.T)),%20kotlin.Function1((kotlin.sequences.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Sequence<T>.partition(     predicate: (T) -> Boolean ): Pair<List<T>, List<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../plus) Returns a sequence containing all elements of the original sequence and then the given [element](../plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.sequences.plus.T)/element). ``` operator fun <T> Sequence<T>.plus(element: T): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](../plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.Array((kotlin.sequences.plus.T)))/elements) array. ``` operator fun <T> Sequence<T>.plus(     elements: Array<out T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](../plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.collections.Iterable((kotlin.sequences.plus.T)))/elements) collection. ``` operator fun <T> Sequence<T>.plus(     elements: Iterable<T> ): Sequence<T> ``` Returns a sequence containing all elements of original sequence and then all elements of the given [elements](../plus#kotlin.sequences%24plus(kotlin.sequences.Sequence((kotlin.sequences.plus.T)),%20kotlin.sequences.Sequence((kotlin.sequences.plus.T)))/elements) sequence. ``` operator fun <T> Sequence<T>.plus(     elements: Sequence<T> ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plusElement](../plus-element) Returns a sequence containing all elements of the original sequence and then the given [element](../plus-element#kotlin.sequences%24plusElement(kotlin.sequences.Sequence((kotlin.sequences.plusElement.T)),%20kotlin.sequences.plusElement.T)/element). ``` fun <T> Sequence<T>.plusElement(element: T): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../reduce) Accumulates value starting with the first element and applying [operation](../reduce#kotlin.sequences%24reduce(kotlin.sequences.Sequence((kotlin.sequences.reduce.T)),%20kotlin.Function2((kotlin.sequences.reduce.S,%20kotlin.sequences.reduce.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Sequence<T>.reduce(     operation: (acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](../reduce-indexed) Accumulates value starting with the first element and applying [operation](../reduce-indexed#kotlin.sequences%24reduceIndexed(kotlin.sequences.Sequence((kotlin.sequences.reduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.reduceIndexed.S,%20kotlin.sequences.reduceIndexed.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. ``` fun <S, T : S> Sequence<T>.reduceIndexed(     operation: (index: Int, acc: S, T) -> S ): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](../reduce-indexed-or-null) Accumulates value starting with the first element and applying [operation](../reduce-indexed-or-null#kotlin.sequences%24reduceIndexedOrNull(kotlin.sequences.Sequence((kotlin.sequences.reduceIndexedOrNull.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.reduceIndexedOrNull.S,%20kotlin.sequences.reduceIndexedOrNull.T,%20)))/operation) from left to right to current accumulator value and each element with its index in the original sequence. ``` fun <S, T : S> Sequence<T>.reduceIndexedOrNull(     operation: (index: Int, acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](../reduce-or-null) Accumulates value starting with the first element and applying [operation](../reduce-or-null#kotlin.sequences%24reduceOrNull(kotlin.sequences.Sequence((kotlin.sequences.reduceOrNull.T)),%20kotlin.Function2((kotlin.sequences.reduceOrNull.S,%20kotlin.sequences.reduceOrNull.T,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <S, T : S> Sequence<T>.reduceOrNull(     operation: (acc: S, T) -> S ): S? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNoNulls](../require-no-nulls) Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException](../../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if there are any `null` elements. ``` fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../running-fold) Returns a sequence containing successive accumulation values generated by applying [operation](../running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../running-fold#kotlin.sequences%24runningFold(kotlin.sequences.Sequence((kotlin.sequences.runningFold.T)),%20kotlin.sequences.runningFold.R,%20kotlin.Function2((kotlin.sequences.runningFold.R,%20kotlin.sequences.runningFold.T,%20)))/initial) value. ``` fun <T, R> Sequence<T>.runningFold(     initial: R,     operation: (acc: R, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](../running-fold-indexed) Returns a sequence containing successive accumulation values generated by applying [operation](../running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with [initial](../running-fold-indexed#kotlin.sequences%24runningFoldIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningFoldIndexed.T)),%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningFoldIndexed.R,%20kotlin.sequences.runningFoldIndexed.T,%20)))/initial) value. ``` fun <T, R> Sequence<T>.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](../running-reduce) Returns a sequence containing successive accumulation values generated by applying [operation](../running-reduce#kotlin.sequences%24runningReduce(kotlin.sequences.Sequence((kotlin.sequences.runningReduce.T)),%20kotlin.Function2((kotlin.sequences.runningReduce.S,%20kotlin.sequences.runningReduce.T,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this sequence. ``` fun <S, T : S> Sequence<T>.runningReduce(     operation: (acc: S, T) -> S ): Sequence<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](../running-reduce-indexed) Returns a sequence containing successive accumulation values generated by applying [operation](../running-reduce-indexed#kotlin.sequences%24runningReduceIndexed(kotlin.sequences.Sequence((kotlin.sequences.runningReduceIndexed.T)),%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.runningReduceIndexed.S,%20kotlin.sequences.runningReduceIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with the first element of this sequence. ``` fun <S, T : S> Sequence<T>.runningReduceIndexed(     operation: (index: Int, acc: S, T) -> S ): Sequence<S> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scan](../scan) Returns a sequence containing successive accumulation values generated by applying [operation](../scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../scan#kotlin.sequences%24scan(kotlin.sequences.Sequence((kotlin.sequences.scan.T)),%20kotlin.sequences.scan.R,%20kotlin.Function2((kotlin.sequences.scan.R,%20kotlin.sequences.scan.T,%20)))/initial) value. ``` fun <T, R> Sequence<T>.scan(     initial: R,     operation: (acc: R, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](../scan-indexed) Returns a sequence containing successive accumulation values generated by applying [operation](../scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/operation) from left to right to each element, its index in the original sequence and current accumulator value that starts with [initial](../scan-indexed#kotlin.sequences%24scanIndexed(kotlin.sequences.Sequence((kotlin.sequences.scanIndexed.T)),%20kotlin.sequences.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.sequences.scanIndexed.R,%20kotlin.sequences.scanIndexed.T,%20)))/initial) value. ``` fun <T, R> Sequence<T>.scanIndexed(     initial: R,     operation: (index: Int, acc: R, T) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [shuffled](../shuffled) Returns a sequence that yields elements of this sequence randomly shuffled. ``` fun <T> Sequence<T>.shuffled(): Sequence<T> ``` Returns a sequence that yields elements of this sequence randomly shuffled using the specified [random](../shuffled#kotlin.sequences%24shuffled(kotlin.sequences.Sequence((kotlin.sequences.shuffled.T)),%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun <T> Sequence<T>.shuffled(random: Random): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../single) Returns the single element, or throws an exception if the sequence is empty or has more than one element. ``` fun <T> Sequence<T>.single(): T ``` Returns the single element matching the given [predicate](../single#kotlin.sequences%24single(kotlin.sequences.Sequence((kotlin.sequences.single.T)),%20kotlin.Function1((kotlin.sequences.single.T,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun <T> Sequence<T>.single(predicate: (T) -> Boolean): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](../single-or-null) Returns single element, or `null` if the sequence is empty or has more than one element. ``` fun <T> Sequence<T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../single-or-null#kotlin.sequences%24singleOrNull(kotlin.sequences.Sequence((kotlin.sequences.singleOrNull.T)),%20kotlin.Function1((kotlin.sequences.singleOrNull.T,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun <T> Sequence<T>.singleOrNull(     predicate: (T) -> Boolean ): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../sorted) Returns a sequence that yields elements of this sequence sorted according to their natural sort order. ``` fun <T : Comparable<T>> Sequence<T>.sorted(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedBy](../sorted-by) Returns a sequence that yields elements of this sequence sorted according to natural sort order of the value returned by specified [selector](../sorted-by#kotlin.sequences%24sortedBy(kotlin.sequences.Sequence((kotlin.sequences.sortedBy.T)),%20kotlin.Function1((kotlin.sequences.sortedBy.T,%20kotlin.sequences.sortedBy.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Sequence<T>.sortedBy(     selector: (T) -> R? ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedByDescending](../sorted-by-descending) Returns a sequence that yields elements of this sequence sorted descending according to natural sort order of the value returned by specified [selector](../sorted-by-descending#kotlin.sequences%24sortedByDescending(kotlin.sequences.Sequence((kotlin.sequences.sortedByDescending.T)),%20kotlin.Function1((kotlin.sequences.sortedByDescending.T,%20kotlin.sequences.sortedByDescending.R?)))/selector) function. ``` fun <T, R : Comparable<R>> Sequence<T>.sortedByDescending(     selector: (T) -> R? ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../sorted-descending) Returns a sequence that yields elements of this sequence sorted descending according to their natural sort order. ``` fun <T : Comparable<T>> Sequence<T>.sortedDescending(): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedWith](../sorted-with) Returns a sequence that yields elements of this sequence sorted according to the specified [comparator](../sorted-with#kotlin.sequences%24sortedWith(kotlin.sequences.Sequence((kotlin.sequences.sortedWith.T)),%20kotlin.Comparator((kotlin.sequences.sortedWith.T)))/comparator). ``` fun <T> Sequence<T>.sortedWith(     comparator: Comparator<in T> ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../sum) Returns the sum of all elements in the sequence. ``` fun Sequence<Byte>.sum(): Int ``` ``` fun Sequence<Short>.sum(): Int ``` ``` fun Sequence<Int>.sum(): Int ``` ``` fun Sequence<Long>.sum(): Long ``` ``` fun Sequence<Float>.sum(): Float ``` ``` fun Sequence<Double>.sum(): Double ``` ``` fun Sequence<UInt>.sum(): UInt ``` ``` fun Sequence<ULong>.sum(): ULong ``` ``` fun Sequence<UByte>.sum(): UInt ``` ``` fun Sequence<UShort>.sum(): UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../sum-by) Returns the sum of all values produced by [selector](../sum-by#kotlin.sequences%24sumBy(kotlin.sequences.Sequence((kotlin.sequences.sumBy.T)),%20kotlin.Function1((kotlin.sequences.sumBy.T,%20kotlin.Int)))/selector) function applied to each element in the sequence. ``` fun <T> Sequence<T>.sumBy(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](../sum-by-double) Returns the sum of all values produced by [selector](../sum-by-double#kotlin.sequences%24sumByDouble(kotlin.sequences.Sequence((kotlin.sequences.sumByDouble.T)),%20kotlin.Function1((kotlin.sequences.sumByDouble.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. ``` fun <T> Sequence<T>.sumByDouble(     selector: (T) -> Double ): Double ``` #### [sumOf](../sum-of) Returns the sum of all values produced by [selector](../sum-of#kotlin.sequences%24sumOf(kotlin.sequences.Sequence((kotlin.sequences.sumOf.T)),%20kotlin.Function1((kotlin.sequences.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the sequence. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun <T> Sequence<T>.sumOf(selector: (T) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Sequence<T>.sumOf(     selector: (T) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun <T> Sequence<T>.sumOf(     selector: (T) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [take](../take) Returns a sequence containing first [n](../take#kotlin.sequences%24take(kotlin.sequences.Sequence((kotlin.sequences.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Sequence<T>.take(n: Int): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../take-while) Returns a sequence containing first elements satisfying the given [predicate](../take-while#kotlin.sequences%24takeWhile(kotlin.sequences.Sequence((kotlin.sequences.takeWhile.T)),%20kotlin.Function1((kotlin.sequences.takeWhile.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Sequence<T>.takeWhile(     predicate: (T) -> Boolean ): Sequence<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../to-collection) Appends all elements to the given [destination](../to-collection#kotlin.sequences%24toCollection(kotlin.sequences.Sequence((kotlin.sequences.toCollection.T)),%20kotlin.sequences.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Sequence<T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](../to-hash-set) Returns a new [HashSet](../../kotlin.collections/-hash-set/index#kotlin.collections.HashSet) of all elements. ``` fun <T> Sequence<T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Returns a [List](../../kotlin.collections/-list/index#kotlin.collections.List) containing all elements. ``` fun <T> Sequence<T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMap](../../kotlin.collections/to-map) Returns a new map containing all key-value pairs from the given sequence of pairs. ``` fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../../kotlin.collections/to-map#kotlin.collections%24toMap(kotlin.sequences.Sequence((kotlin.Pair((kotlin.collections.toMap.K,%20kotlin.collections.toMap.V)))),%20kotlin.collections.toMap.M)/destination) mutable map with key-value pairs from the given sequence of pairs. ``` fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.toMap(     destination: M ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this sequence. ``` fun <T> Sequence<T>.toMutableList(): MutableList<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableSet](../to-mutable-set) Returns a new [MutableSet](../../kotlin.collections/-mutable-set/index#kotlin.collections.MutableSet) containing all distinct elements from the given sequence. ``` fun <T> Sequence<T>.toMutableSet(): MutableSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](../to-set) Returns a [Set](../../kotlin.collections/-set/index#kotlin.collections.Set) of all elements. ``` fun <T> Sequence<T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun <T : Comparable<T>> Sequence<T>.toSortedSet(): SortedSet<T> ``` ``` fun <T> Sequence<T>.toSortedSet(     comparator: Comparator<in T> ): SortedSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unzip](../unzip) Returns a pair of lists, where *first* list is built from the first values of each pair from this sequence, *second* list is built from the second values of each pair from this sequence. ``` fun <T, R> Sequence<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../windowed) Returns a sequence of snapshots of the window of the given [size](../windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this sequence with the given [step](../windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a list. ``` fun <T> Sequence<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): Sequence<List<T>> ``` Returns a sequence of results of applying the given [transform](../windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/transform) function to an each list representing a view over the window of the given [size](../windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/size) sliding along this sequence with the given [step](../windowed#kotlin.sequences%24windowed(kotlin.sequences.Sequence((kotlin.sequences.windowed.T)),%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.collections.List((kotlin.sequences.windowed.T)),%20kotlin.sequences.windowed.R)))/step). ``` fun <T, R> Sequence<T>.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (List<T>) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](../with-index) Returns a sequence that wraps each element of the original sequence into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Sequence<T>.withIndex(): Sequence<IndexedValue<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [zip](../zip) Returns a sequence of values built from the elements of `this` sequence and the [other](../zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)))/other) sequence with the same index. The resulting sequence ends as soon as the shortest input sequence ends. ``` infix fun <T, R> Sequence<T>.zip(     other: Sequence<R> ): Sequence<Pair<T, R>> ``` Returns a sequence of values built from the elements of `this` sequence and the [other](../zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)),%20kotlin.Function2((kotlin.sequences.zip.T,%20kotlin.sequences.zip.R,%20kotlin.sequences.zip.V)))/other) sequence with the same index using the provided [transform](../zip#kotlin.sequences%24zip(kotlin.sequences.Sequence((kotlin.sequences.zip.T)),%20kotlin.sequences.Sequence((kotlin.sequences.zip.R)),%20kotlin.Function2((kotlin.sequences.zip.T,%20kotlin.sequences.zip.R,%20kotlin.sequences.zip.V)))/transform) function applied to each pair of elements. The resulting sequence ends as soon as the shortest input sequence ends. ``` fun <T, R, V> Sequence<T>.zip(     other: Sequence<R>,     transform: (a: T, b: R) -> V ): Sequence<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](../zip-with-next) Returns a sequence of pairs of each two adjacent elements in this sequence. ``` fun <T> Sequence<T>.zipWithNext(): Sequence<Pair<T, T>> ``` Returns a sequence containing the results of applying the given [transform](../zip-with-next#kotlin.sequences%24zipWithNext(kotlin.sequences.Sequence((kotlin.sequences.zipWithNext.T)),%20kotlin.Function2((kotlin.sequences.zipWithNext.T,%20,%20kotlin.sequences.zipWithNext.R)))/transform) function to an each pair of two adjacent elements in this sequence. ``` fun <T, R> Sequence<T>.zipWithNext(     transform: (a: T, b: T) -> R ): Sequence<R> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0) #### [FileTreeWalk](../../kotlin.io/-file-tree-walk/index) This class is intended to implement different file traversal methods. It allows to iterate through all files inside a given directory. ``` class FileTreeWalk : Sequence<File> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.sequences](../index) / [Sequence](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract operator fun iterator(): Iterator<T> ``` Returns an [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) that returns the values from the sequence. Throws an exception if the sequence is constrained to be iterated once and `iterator` is invoked the second time. kotlin SequenceScope SequenceScope ============= [kotlin-stdlib](../../../../../../index) / [kotlin.sequences](../index) / [SequenceScope](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` abstract class SequenceScope<in T> ``` The scope for yielding values of a [Sequence](../-sequence/index) or an [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator), provides <yield> and [yieldAll](yield-all) suspension functions. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = sequence { val start = 0 // yielding a single value yield(start) // yielding an iterable yieldAll(1..5 step 2) // yielding an infinite sequence yieldAll(generateSequence(8) { it * 3 }) } println(sequence.take(7).toList()) // [0, 1, 3, 5, 8, 24, 72] //sampleEnd } ``` ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun fibonacci() = sequence { var terms = Pair(0, 1) // this sequence is infinite while (true) { yield(terms.first) terms = Pair(terms.second, terms.first + terms.second) } } println(fibonacci().take(10).toList()) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] //sampleEnd } ``` **See Also** [sequence](../sequence) [iterator](../iterator) Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <yield> Yields a value to the [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) being built and suspends until the next value is requested. ``` abstract suspend fun yield(value: T) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [yieldAll](yield-all) Yields all values from the `iterator` to the [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) being built and suspends until all these values are iterated and the next one is requested. ``` abstract suspend fun yieldAll(iterator: Iterator<T>) ``` Yields a collections of values to the [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) being built and suspends until all these values are iterated and the next one is requested. ``` suspend fun yieldAll(elements: Iterable<T>) ``` Yields potentially infinite sequence of values to the [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) being built and suspends until all these values are iterated and the next one is requested. ``` suspend fun yieldAll(sequence: Sequence<T>) ``` kotlin yieldAll yieldAll ======== [kotlin-stdlib](../../../../../../index) / [kotlin.sequences](../index) / [SequenceScope](index) / [yieldAll](yield-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract suspend fun yieldAll(iterator: Iterator<T>) ``` Yields all values from the `iterator` to the [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) being built and suspends until all these values are iterated and the next one is requested. The sequence of values returned by the given iterator can be potentially infinite. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = sequence { val start = 0 // yielding a single value yield(start) // yielding an iterable yieldAll(1..5 step 2) // yielding an infinite sequence yieldAll(generateSequence(8) { it * 3 }) } println(sequence.take(7).toList()) // [0, 1, 3, 5, 8, 24, 72] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` suspend fun yieldAll(elements: Iterable<T>) ``` Yields a collections of values to the [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) being built and suspends until all these values are iterated and the next one is requested. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = sequence { val start = 0 // yielding a single value yield(start) // yielding an iterable yieldAll(1..5 step 2) // yielding an infinite sequence yieldAll(generateSequence(8) { it * 3 }) } println(sequence.take(7).toList()) // [0, 1, 3, 5, 8, 24, 72] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` suspend fun yieldAll(sequence: Sequence<T>) ``` Yields potentially infinite sequence of values to the [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) being built and suspends until all these values are iterated and the next one is requested. The sequence can be potentially infinite. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = sequence { val start = 0 // yielding a single value yield(start) // yielding an iterable yieldAll(1..5 step 2) // yielding an infinite sequence yieldAll(generateSequence(8) { it * 3 }) } println(sequence.take(7).toList()) // [0, 1, 3, 5, 8, 24, 72] //sampleEnd } ``` kotlin yield yield ===== [kotlin-stdlib](../../../../../../index) / [kotlin.sequences](../index) / [SequenceScope](index) / <yield> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract suspend fun yield(value: T) ``` Yields a value to the [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) being built and suspends until the next value is requested. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = sequence { val start = 0 // yielding a single value yield(start) // yielding an iterable yieldAll(1..5 step 2) // yielding an infinite sequence yieldAll(generateSequence(8) { it * 3 }) } println(sequence.take(7).toList()) // [0, 1, 3, 5, 8, 24, 72] //sampleEnd } ``` ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun fibonacci() = sequence { var terms = Pair(0, 1) // this sequence is infinite while (true) { yield(terms.first) terms = Pair(terms.second, terms.first + terms.second) } } println(fibonacci().take(10).toList()) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] //sampleEnd } ``` kotlin Extensions for java.util.Enumeration Extensions for java.util.Enumeration ==================================== [kotlin-stdlib](../../../../../../index) / [kotlin.sequences](../index) / [java.util.Enumeration](index) **Platform and version requirements:** JVM (1.0) #### [asSequence](as-sequence) Creates a sequence that returns all values from this enumeration. The sequence is constrained to be iterated only once. ``` fun <T> Enumeration<T>.asSequence(): Sequence<T> ``` kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../../index) / [kotlin.sequences](../index) / [java.util.Enumeration](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.0) ``` fun <T> Enumeration<T>.asSequence(): Sequence<T> ``` Creates a sequence that returns all values from this enumeration. The sequence is constrained to be iterated only once. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = java.util.Hashtable<String, Int>() numbers.put("one", 1) numbers.put("two", 2) numbers.put("three", 3) // when you have an Enumeration from some old code val enumeration: java.util.Enumeration<String> = numbers.keys() // you can wrap it in a sequence and transform further with sequence operations val sequence = enumeration.asSequence().sorted() println(sequence.toList()) // [one, three, two] // the resulting sequence is one-shot // sequence.toList() // will fail //sampleEnd } ``` kotlin Package kotlin.system Package kotlin.system ===================== [kotlin-stdlib](../../../../../index) / [kotlin.system](index) System-related utility functions. Functions --------- **Platform and version requirements:** JVM (1.0), Native (1.0) #### [exitProcess](exit-process) Terminates the currently running process. ``` fun exitProcess(status: Int): Nothing ``` **Platform and version requirements:** Native (1.3) #### [getTimeMicros](get-time-micros) Gets current system time in microseconds since certain moment in the past, only delta between two subsequent calls makes sense. ``` fun getTimeMicros(): Long ``` **Platform and version requirements:** Native (1.3) #### [getTimeMillis](get-time-millis) Gets current system time in milliseconds since certain moment in the past, only delta between two subsequent calls makes sense. ``` fun getTimeMillis(): Long ``` **Platform and version requirements:** Native (1.3) #### [getTimeNanos](get-time-nanos) Gets current system time in nanoseconds since certain moment in the past, only delta between two subsequent calls makes sense. ``` fun getTimeNanos(): Long ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### [measureNanoTime](measure-nano-time) Executes the given [block](measure-nano-time#kotlin.system%24measureNanoTime(kotlin.Function0((kotlin.Unit)))/block) and returns elapsed time in nanoseconds. ``` fun measureNanoTime(block: () -> Unit): Long ``` **Platform and version requirements:** Native (1.3) #### [measureTimeMicros](measure-time-micros) Executes the given [block](measure-time-micros#kotlin.system%24measureTimeMicros(kotlin.Function0((kotlin.Unit)))/block) and returns elapsed time in microseconds (Kotlin/Native only). ``` fun measureTimeMicros(block: () -> Unit): Long ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### [measureTimeMillis](measure-time-millis) Executes the given [block](measure-time-millis#kotlin.system%24measureTimeMillis(kotlin.Function0((kotlin.Unit)))/block) and returns elapsed time in milliseconds. ``` fun measureTimeMillis(block: () -> Unit): Long ``` kotlin getTimeMillis getTimeMillis ============= [kotlin-stdlib](../../../../../index) / [kotlin.system](index) / [getTimeMillis](get-time-millis) **Platform and version requirements:** Native (1.3) ``` fun getTimeMillis(): Long ``` Gets current system time in milliseconds since certain moment in the past, only delta between two subsequent calls makes sense. kotlin measureTimeMillis measureTimeMillis ================= [kotlin-stdlib](../../../../../index) / [kotlin.system](index) / [measureTimeMillis](measure-time-millis) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` inline fun measureTimeMillis(block: () -> Unit): Long ``` Executes the given [block](measure-time-millis#kotlin.system%24measureTimeMillis(kotlin.Function0((kotlin.Unit)))/block) and returns elapsed time in milliseconds. ``` import kotlin.system.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> val timeInMillis = measureTimeMillis { numbers = buildList { addAll(0..100) shuffle() sortDescending() } } // here numbers are initialized and sorted println(numbers.first()) // 100 println("(The operation took $timeInMillis ms)") //sampleEnd } ``` kotlin exitProcess exitProcess =========== [kotlin-stdlib](../../../../../index) / [kotlin.system](index) / [exitProcess](exit-process) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` fun exitProcess(status: Int): Nothing ``` Terminates the currently running process. Parameters ---------- `status` - serves as a status code; by convention, a nonzero status code indicates abnormal termination. **Return** This method never returns normally. kotlin measureNanoTime measureNanoTime =============== [kotlin-stdlib](../../../../../index) / [kotlin.system](index) / [measureNanoTime](measure-nano-time) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` inline fun measureNanoTime(block: () -> Unit): Long ``` Executes the given [block](measure-nano-time#kotlin.system%24measureNanoTime(kotlin.Function0((kotlin.Unit)))/block) and returns elapsed time in nanoseconds. ``` import kotlin.system.* fun main(args: Array<String>) { //sampleStart var sqrt = 0 val number = 1000 val timeInNanos = measureNanoTime { while (sqrt * sqrt < number) sqrt++ } println("(The operation took $timeInNanos ns)") println("The approximate square root of $number is between ${sqrt - 1} and $sqrt") //sampleEnd } ``` kotlin getTimeNanos getTimeNanos ============ [kotlin-stdlib](../../../../../index) / [kotlin.system](index) / [getTimeNanos](get-time-nanos) **Platform and version requirements:** Native (1.3) ``` fun getTimeNanos(): Long ``` Gets current system time in nanoseconds since certain moment in the past, only delta between two subsequent calls makes sense. kotlin getTimeMicros getTimeMicros ============= [kotlin-stdlib](../../../../../index) / [kotlin.system](index) / [getTimeMicros](get-time-micros) **Platform and version requirements:** Native (1.3) ``` fun getTimeMicros(): Long ``` Gets current system time in microseconds since certain moment in the past, only delta between two subsequent calls makes sense. kotlin measureTimeMicros measureTimeMicros ================= [kotlin-stdlib](../../../../../index) / [kotlin.system](index) / [measureTimeMicros](measure-time-micros) **Platform and version requirements:** Native (1.3) ``` inline fun measureTimeMicros(block: () -> Unit): Long ``` Executes the given [block](measure-time-micros#kotlin.system%24measureTimeMicros(kotlin.Function0((kotlin.Unit)))/block) and returns elapsed time in microseconds (Kotlin/Native only). kotlin localStorage localStorage ============ [kotlin-stdlib](../../../../../index) / [kotlin.browser](index) / [localStorage](local-storage) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") val localStorage: Storage ``` **Deprecated:** This API is moved to another package, use 'kotlinx.browser.localStorage' instead. kotlin window window ====== [kotlin-stdlib](../../../../../index) / [kotlin.browser](index) / <window> **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") val window: Window ``` **Deprecated:** This API is moved to another package, use 'kotlinx.browser.window' instead. kotlin Package kotlin.browser Package kotlin.browser ====================== [kotlin-stdlib](../../../../../index) / [kotlin.browser](index) Access to top-level properties (`document`, `window` etc.) in the browser environment. Properties ---------- **Platform and version requirements:** JS (1.1) #### <document> ``` val document: Document ``` **Platform and version requirements:** JS (1.1) #### [localStorage](local-storage) ``` val localStorage: Storage ``` **Platform and version requirements:** JS (1.1) #### [sessionStorage](session-storage) ``` val sessionStorage: Storage ``` **Platform and version requirements:** JS (1.1) #### <window> ``` val window: Window ``` kotlin sessionStorage sessionStorage ============== [kotlin-stdlib](../../../../../index) / [kotlin.browser](index) / [sessionStorage](session-storage) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") val sessionStorage: Storage ``` **Deprecated:** This API is moved to another package, use 'kotlinx.browser.sessionStorage' instead. kotlin document document ======== [kotlin-stdlib](../../../../../index) / [kotlin.browser](index) / <document> **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") val document: Document ``` **Deprecated:** This API is moved to another package, use 'kotlinx.browser.document' instead. kotlin foldIndexed foldIndexed =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [foldIndexed](fold-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R> CharSequence.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): R ``` Accumulates value starting with [initial](fold-indexed#kotlin.text%24foldIndexed(kotlin.CharSequence,%20kotlin.text.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.foldIndexed.R,%20kotlin.Char,%20)))/initial) value and applying [operation](fold-indexed#kotlin.text%24foldIndexed(kotlin.CharSequence,%20kotlin.text.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.foldIndexed.R,%20kotlin.Char,%20)))/operation) from left to right to current accumulator value and each character with its index in the original char sequence. Returns the specified [initial](fold-indexed#kotlin.text%24foldIndexed(kotlin.CharSequence,%20kotlin.text.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.foldIndexed.R,%20kotlin.Char,%20)))/initial) value if the char sequence is empty. Parameters ---------- `operation` - function that takes the index of a character, current accumulator value and the character itself, and calculates the next accumulator value. kotlin all all === [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <all> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.all(     predicate: (Char) -> Boolean ): Boolean ``` Returns `true` if all characters match the given [predicate](all#kotlin.text%24all(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). Note that if the char sequence contains no characters, the function returns `true` because there are no characters in it that *do not* match the predicate. See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.all { isEven(it) } is ${zeroToTen.all { isEven(it) }}") // false println("zeroToTen.all(isEven) is ${zeroToTen.all(isEven)}") // false val evens = zeroToTen.map { it * 2 } println("evens.all { isEven(it) } is ${evens.all { isEven(it) }}") // true val emptyList = emptyList<Int>() println("emptyList.all { false } is ${emptyList.all { false }}") // true //sampleEnd } ``` kotlin reduceIndexedOrNull reduceIndexedOrNull =================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [reduceIndexedOrNull](reduce-indexed-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun CharSequence.reduceIndexedOrNull(     operation: (index: Int, acc: Char, Char) -> Char ): Char? ``` Accumulates value starting with the first character and applying [operation](reduce-indexed-or-null#kotlin.text%24reduceIndexedOrNull(kotlin.CharSequence,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each character with its index in the original char sequence. Returns `null` if the char sequence is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceOrNull { acc, string -> acc + string }) // abcd println(strings.reduceIndexedOrNull { index, acc, string -> acc + string + index }) // ab1c2d3 println(emptyList<String>().reduceOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of a character, current accumulator value and the character itself, and calculates the next accumulator value.
programming_docs
kotlin single single ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <single> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.single(): Char ``` Returns the single character, or throws an exception if the char sequence is empty or has more than one character. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.single(     predicate: (Char) -> Boolean ): Char ``` Returns the single character matching the given [predicate](single#kotlin.text%24single(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching character. kotlin reduceOrNull reduceOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [reduceOrNull](reduce-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun CharSequence.reduceOrNull(     operation: (acc: Char, Char) -> Char ): Char? ``` Accumulates value starting with the first character and applying [operation](reduce-or-null#kotlin.text%24reduceOrNull(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each character. Returns `null` if the char sequence is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceOrNull { acc, string -> acc + string }) // abcd println(strings.reduceIndexedOrNull { index, acc, string -> acc + string + index }) // ab1c2d3 println(emptyList<String>().reduceOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and a character, and calculates the next accumulator value. kotlin runningReduce runningReduce ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [runningReduce](running-reduce) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun CharSequence.runningReduce(     operation: (acc: Char, Char) -> Char ): List<Char> ``` Returns a list containing successive accumulation values generated by applying [operation](running-reduce#kotlin.text%24runningReduce(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to each character and current accumulator value that starts with the first character of this char sequence. Note that `acc` value passed to [operation](running-reduce#kotlin.text%24runningReduce(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningReduce { acc, string -> acc + string }) // [a, ab, abc, abcd] println(strings.runningReduceIndexed { index, acc, string -> acc + string + index }) // [a, ab1, ab1c2, ab1c2d3] println(emptyList<String>().runningReduce { _, _ -> "X" }) // [] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and a character, and calculates the next accumulator value. kotlin ifEmpty ifEmpty ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [ifEmpty](if-empty) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : CharSequence, C : R ``` Returns this char sequence if it's not empty or the result of calling [defaultValue](if-empty#kotlin.text%24ifEmpty(kotlin.text.ifEmpty.C,%20kotlin.Function0((kotlin.text.ifEmpty.R)))/defaultValue) function if the char sequence is empty. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val empty = "" val emptyOrNull: String? = empty.ifEmpty { null } println(emptyOrNull) // null val emptyOrDefault = empty.ifEmpty { "default" } println(emptyOrDefault) // default val nonEmpty = "abc" val sameString = nonEmpty.ifEmpty { "def" } println("nonEmpty === sameString is ${nonEmpty === sameString}") // true //sampleEnd } ``` kotlin toULongOrNull toULongOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toULongOrNull](to-u-long-or-null) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun String.toULongOrNull(): ULong? ``` Parses the string as an [ULong](../kotlin/-u-long/index) number and returns the result or `null` if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun String.toULongOrNull(radix: Int): ULong? ``` Parses the string as an [ULong](../kotlin/-u-long/index) number and returns the result or `null` if the string is not a valid representation of a number. Exceptions ---------- `IllegalArgumentException` - when [radix](to-u-long-or-null#kotlin.text%24toULongOrNull(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin contains contains ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun CharSequence.contains(     other: CharSequence,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this char sequence contains the specified [other](contains#kotlin.text%24contains(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) sequence of characters as a substring. Parameters ---------- `ignoreCase` - `true` to ignore character case when comparing strings. By default `false`. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun CharSequence.contains(     char: Char,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this char sequence contains the specified character [char](contains#kotlin.text%24contains(kotlin.CharSequence,%20kotlin.Char,%20kotlin.Boolean)/char). Parameters ---------- `ignoreCase` - `true` to ignore character case when comparing characters. By default `false`. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun CharSequence.contains(regex: Regex): Boolean ``` Returns `true` if this char sequence contains at least one match of the specified regular expression [regex](contains#kotlin.text%24contains(kotlin.CharSequence,%20kotlin.text.Regex)/regex). kotlin mapNotNull mapNotNull ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [mapNotNull](map-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R : Any> CharSequence.mapNotNull(     transform: (Char) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-not-null#kotlin.text%24mapNotNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.mapNotNull.R?)))/transform) function to each character in the original char sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings: List<String> = listOf("12a", "45", "", "3") val ints: List<Int> = strings.mapNotNull { it.toIntOrNull() } println(ints) // [45, 3] println(ints.sum()) // 48 //sampleEnd } ``` kotlin associateByTo associateByTo ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [associateByTo](associate-by-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, M : MutableMap<in K, in Char>> CharSequence.associateByTo(     destination: M,     keySelector: (Char) -> K ): M ``` Populates and returns the [destination](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)))/keySelector) function applied to each character of the given char sequence and value is the character itself. If any two characters would have the same key returned by [keySelector](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)))/keySelector) the last one gets added to the map. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "bonne journée" // associate each character by its code val result = mutableMapOf<Int, Char>() string.associateByTo(result) { char -> char.code } // notice each char code occurs only once println(result) // {98=b, 111=o, 110=n, 101=e, 32= , 106=j, 117=u, 114=r, 233=é} //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V, M : MutableMap<in K, in V>> CharSequence.associateByTo(     destination: M,     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): M ``` Populates and returns the [destination](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.V)))/valueTransform) function applied to characters of the given char sequence. If any two characters would have the same key returned by [keySelector](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.V)))/keySelector) the last one gets added to the map. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "bonne journée" // associate each character by the code of its upper case equivalent and transform the character to upper case val result = mutableMapOf<Int, Char>() string.associateByTo(result, { char -> char.uppercaseChar().code }, { char -> char.uppercaseChar() }) // notice each char code occurs only once println(result) // {66=B, 79=O, 78=N, 69=E, 32= , 74=J, 85=U, 82=R, 201=É} //sampleEnd } ``` kotlin replaceAfterLast replaceAfterLast ================ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [replaceAfterLast](replace-after-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceAfterLast(     delimiter: String,     replacement: String,     missingDelimiterValue: String = this ): String ``` ``` fun String.replaceAfterLast(     delimiter: Char,     replacement: String,     missingDelimiterValue: String = this ): String ``` Replace part of string after the last occurrence of given delimiter with the [replacement](replace-after-last#kotlin.text%24replaceAfterLast(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.String)/replacement) string. If the string does not contain the delimiter, returns [missingDelimiterValue](replace-after-last#kotlin.text%24replaceAfterLast(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. kotlin uppercaseChar uppercaseChar ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [uppercaseChar](uppercase-char) **Platform and version requirements:** JVM (1.5), JS (1.5) ``` fun Char.uppercaseChar(): Char ``` Converts this character to upper case using Unicode mapping rules of the invariant locale. This function performs one-to-one character mapping. To support one-to-many character mapping use the [uppercase](uppercase#kotlin.text%24uppercase(kotlin.Char)) function. If this character has no mapping equivalent, the character itself is returned. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('a', 'ω', '1', 'ʼn', 'A', '+', 'ß') val uppercaseChar = chars.map { it.uppercaseChar() } val uppercase = chars.map { it.uppercase() } println(uppercaseChar) // [A, Ω, 1, ʼn, A, +, ß] println(uppercase) // [A, Ω, 1, ʼN, A, +, SS] //sampleEnd } ``` kotlin toBigIntegerOrNull toBigIntegerOrNull ================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toBigIntegerOrNull](to-big-integer-or-null) **Platform and version requirements:** JVM (1.2) ``` fun String.toBigIntegerOrNull(): BigInteger? ``` Parses the string as a [java.math.BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number and returns the result or `null` if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.2) ``` fun String.toBigIntegerOrNull(radix: Int): BigInteger? ``` Parses the string as a [java.math.BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number and returns the result or `null` if the string is not a valid representation of a number. Exceptions ---------- `IllegalArgumentException` - when [radix](to-big-integer-or-null#kotlin.text%24toBigIntegerOrNull(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin appendln appendln ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <appendln> **Platform and version requirements:** Native (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: String ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: Boolean ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: Byte ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: Short ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: Int ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: Long ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: Float ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: Double ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(     it: Any? ): StringBuilder ``` **Deprecated:** Use appendLine instead ``` @DeprecatedSinceKotlin("1.4", "1.6") fun StringBuilder.appendln(): StringBuilder ``` **Deprecated:** Use appendLine instead kotlin toInt toInt ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.toInt(): Int ``` Parses the string as an [Int](../kotlin/-int/index#kotlin.Int) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.toInt(radix: Int): Int ``` Parses the string as an [Int](../kotlin/-int/index#kotlin.Int) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. `IllegalArgumentException` - when [radix](to-int#kotlin.text%24toInt(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin isNotBlank isNotBlank ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isNotBlank](is-not-blank) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.isNotBlank(): Boolean ``` Returns `true` if this char sequence is not empty and contains some characters except of whitespace characters. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun validateName(name: String): String { require(name.isNotBlank()) { "Name cannot be blank" } return name } println(validateName("Adam")) // Adam // validateName("") // will fail // validateName(" \t\n") // will fail //sampleEnd } ``` kotlin any any === [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <any> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.any(): Boolean ``` Returns `true` if char sequence has at least one character. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val emptyList = emptyList<Int>() println("emptyList.any() is ${emptyList.any()}") // false val nonEmptyList = listOf(1, 2, 3) println("nonEmptyList.any() is ${nonEmptyList.any()}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.any(     predicate: (Char) -> Boolean ): Boolean ``` Returns `true` if at least one character matches the given [predicate](any#kotlin.text%24any(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val isEven: (Int) -> Boolean = { it % 2 == 0 } val zeroToTen = 0..10 println("zeroToTen.any { isEven(it) } is ${zeroToTen.any { isEven(it) }}") // true println("zeroToTen.any(isEven) is ${zeroToTen.any(isEven)}") // true val odds = zeroToTen.map { it * 2 + 1 } println("odds.any { isEven(it) } is ${odds.any { isEven(it) }}") // false val emptyList = emptyList<Int>() println("emptyList.any { true } is ${emptyList.any { true }}") // false //sampleEnd } ``` kotlin map map === [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <map> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R> CharSequence.map(     transform: (Char) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](map#kotlin.text%24map(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.map.R)))/transform) function to each character in the original char sequence. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "kotlin" println(string.map { it.uppercaseChar() }) // [K, O, T, L, I, N] //sampleEnd } ``` kotlin toByte toByte ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.toByte(): Byte ``` Parses the string as a signed [Byte](../kotlin/-byte/index#kotlin.Byte) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.toByte(radix: Int): Byte ``` Parses the string as a signed [Byte](../kotlin/-byte/index#kotlin.Byte) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. `IllegalArgumentException` - when [radix](to-byte#kotlin.text%24toByte(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion.
programming_docs
kotlin reduceIndexed reduceIndexed ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [reduceIndexed](reduce-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.reduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): Char ``` Accumulates value starting with the first character and applying [operation](reduce-indexed#kotlin.text%24reduceIndexed(kotlin.CharSequence,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each character with its index in the original char sequence. Throws an exception if this char sequence is empty. If the char sequence can be empty in an expected way, please use [reduceIndexedOrNull](reduce-indexed-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduce { acc, string -> acc + string }) // abcd println(strings.reduceIndexed { index, acc, string -> acc + string + index }) // ab1c2d3 // emptyList<Int>().reduce { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of a character, current accumulator value and the character itself, and calculates the next accumulator value. kotlin replaceAfter replaceAfter ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [replaceAfter](replace-after) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceAfter(     delimiter: Char,     replacement: String,     missingDelimiterValue: String = this ): String ``` ``` fun String.replaceAfter(     delimiter: String,     replacement: String,     missingDelimiterValue: String = this ): String ``` Replace part of string after the first occurrence of given delimiter with the [replacement](replace-after#kotlin.text%24replaceAfter(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/replacement) string. If the string does not contain the delimiter, returns [missingDelimiterValue](replace-after#kotlin.text%24replaceAfter(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. kotlin sumByDouble sumByDouble =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [sumByDouble](sum-by-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") inline fun CharSequence.sumByDouble(     selector: (Char) -> Double ): Double ``` **Deprecated:** Use sumOf instead. Returns the sum of all values produced by [selector](sum-by-double#kotlin.text%24sumByDouble(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence. kotlin indexOfAny indexOfAny ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [indexOfAny](index-of-any) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.indexOfAny(     chars: CharArray,     startIndex: Int = 0,     ignoreCase: Boolean = false ): Int ``` Finds the index of the first occurrence of any of the specified [chars](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/chars) in this char sequence, starting from the specified [startIndex](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. Parameters ---------- `ignoreCase` - `true` to ignore character case when matching a character. By default `false`. **Return** An index of the first occurrence of matched character from [chars](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/chars) or -1 if none of [chars](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/chars) are found. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.indexOfAny(     strings: Collection<String>,     startIndex: Int = 0,     ignoreCase: Boolean = false ): Int ``` Finds the index of the first occurrence of any of the specified [strings](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) in this char sequence, starting from the specified [startIndex](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. Parameters ---------- `ignoreCase` - `true` to ignore character case when matching a string. By default `false`. **Return** An index of the first occurrence of matched string from [strings](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) or -1 if none of [strings](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) are found. To avoid ambiguous results when strings in [strings](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) have characters in common, this method proceeds from the beginning to the end of this string, and finds at each position the first element in [strings](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) that matches this string at that position. kotlin format format ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <format> **Platform and version requirements:** JVM (1.0) ``` fun String.format(vararg args: Any?): String ``` Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the default locale. **Platform and version requirements:** JVM (1.0) ``` fun String.Companion.format(     format: String,     vararg args: Any? ): String ``` Uses the provided [format](format#kotlin.text%24format(kotlin.String.Companion,%20kotlin.String,%20kotlin.Array((kotlin.Any?)))/format) as a format string and returns a string obtained by substituting the specified arguments, using the default locale. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4") fun String.format(     locale: Locale,     vararg args: Any? ): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. **Platform and version requirements:** JVM (1.4) ``` @JvmName("formatNullable") fun String.format(     locale: Locale?,     vararg args: Any? ): String ``` Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. If [locale](format#kotlin.text%24format(kotlin.String,%20java.util.Locale?,%20kotlin.Array((kotlin.Any?)))/locale) is `null` then no localization is applied. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4") fun String.Companion.format(     locale: Locale,     format: String,     vararg args: Any? ): String ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. Uses the provided [format](format#kotlin.text%24format(kotlin.String.Companion,%20java.util.Locale,%20kotlin.String,%20kotlin.Array((kotlin.Any?)))/format) as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. **Platform and version requirements:** JVM (1.4) ``` @JvmName("formatNullable") fun String.Companion.format(     locale: Locale?,     format: String,     vararg args: Any? ): String ``` Uses the provided [format](format#kotlin.text%24format(kotlin.String.Companion,%20java.util.Locale?,%20kotlin.String,%20kotlin.Array((kotlin.Any?)))/format) as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. If [locale](format#kotlin.text%24format(kotlin.String.Companion,%20java.util.Locale?,%20kotlin.String,%20kotlin.Array((kotlin.Any?)))/locale) is `null` then no localization is applied. kotlin toList toList ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toList](to-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.toList(): List<Char> ``` Returns a [List](../kotlin.collections/-list/index#kotlin.collections.List) containing all characters. kotlin findLastAnyOf findLastAnyOf ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [findLastAnyOf](find-last-any-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.findLastAnyOf(     strings: Collection<String>,     startIndex: Int = lastIndex,     ignoreCase: Boolean = false ): Pair<Int, String>? ``` Finds the last occurrence of any of the specified [strings](find-last-any-of#kotlin.text%24findLastAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) in this char sequence, starting from the specified [startIndex](find-last-any-of#kotlin.text%24findLastAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. Parameters ---------- `startIndex` - The index of character to start searching at. The search proceeds backward toward the beginning of the string. `ignoreCase` - `true` to ignore character case when matching a string. By default `false`. **Return** A pair of an index of the last occurrence of matched string from [strings](find-last-any-of#kotlin.text%24findLastAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) and the string matched or `null` if none of [strings](find-last-any-of#kotlin.text%24findLastAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) are found. To avoid ambiguous results when strings in [strings](find-last-any-of#kotlin.text%24findLastAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) have characters in common, this method proceeds from the end toward the beginning of this string, and finds at each position the first element in [strings](find-last-any-of#kotlin.text%24findLastAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) that matches this string at that position. kotlin toMutableList toMutableList ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toMutableList](to-mutable-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.toMutableList(): MutableList<Char> ``` Returns a new [MutableList](../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all characters of this char sequence. kotlin codePointCount codePointCount ============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [codePointCount](code-point-count) **Platform and version requirements:** JVM (1.0) ``` fun String.codePointCount(     beginIndex: Int,     endIndex: Int ): Int ``` Returns the number of Unicode code points in the specified text range of this String. kotlin forEach forEach ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [forEach](for-each) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.forEach(action: (Char) -> Unit) ``` Performs the given [action](for-each#kotlin.text%24forEach(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Unit)))/action) on each character. kotlin drop drop ==== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <drop> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.drop(n: Int): CharSequence ``` Returns a subsequence of this char sequence with the first [n](drop#kotlin.text%24drop(kotlin.CharSequence,%20kotlin.Int)/n) characters removed. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.drop(6)) // st Grade>>> println(string.dropLast(6)) // <<<First Gr println(string.dropWhile { !it.isLetter() }) // First Grade>>> println(string.dropLastWhile { !it.isLetter() }) // <<<First Grade //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](drop#kotlin.text%24drop(kotlin.CharSequence,%20kotlin.Int)/n) is negative. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.drop(n: Int): String ``` Returns a string with the first [n](drop#kotlin.text%24drop(kotlin.String,%20kotlin.Int)/n) characters removed. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.drop(6)) // st Grade>>> println(string.dropLast(6)) // <<<First Gr println(string.dropWhile { !it.isLetter() }) // First Grade>>> println(string.dropLastWhile { !it.isLetter() }) // <<<First Grade //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](drop#kotlin.text%24drop(kotlin.String,%20kotlin.Int)/n) is negative. kotlin replaceRange replaceRange ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [replaceRange](replace-range) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.replaceRange(     startIndex: Int,     endIndex: Int,     replacement: CharSequence ): CharSequence ``` Returns a char sequence with content of this char sequence where its part at the given range is replaced with the [replacement](replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.CharSequence)/replacement) char sequence. Parameters ---------- `startIndex` - the index of the first character to be replaced. `endIndex` - the index of the first character after the replacement to keep in the string. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceRange(     startIndex: Int,     endIndex: Int,     replacement: CharSequence ): String ``` Replaces the part of the string at the given range with the [replacement](replace-range#kotlin.text%24replaceRange(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.CharSequence)/replacement) char sequence. Parameters ---------- `startIndex` - the index of the first character to be replaced. `endIndex` - the index of the first character after the replacement to keep in the string. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.replaceRange(     range: IntRange,     replacement: CharSequence ): CharSequence ``` Returns a char sequence with content of this char sequence where its part at the given [range](replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/range) is replaced with the [replacement](replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/replacement) char sequence. The end index of the [range](replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/range) is included in the part to be replaced. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceRange(     range: IntRange,     replacement: CharSequence ): String ``` Replace the part of string at the given [range](replace-range#kotlin.text%24replaceRange(kotlin.String,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/range) with the [replacement](replace-range#kotlin.text%24replaceRange(kotlin.String,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/replacement) string. The end index of the [range](replace-range#kotlin.text%24replaceRange(kotlin.String,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/range) is included in the part to be replaced. kotlin take take ==== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <take> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.take(n: Int): CharSequence ``` Returns a subsequence of this char sequence containing the first [n](take#kotlin.text%24take(kotlin.CharSequence,%20kotlin.Int)/n) characters from this char sequence, or the entire char sequence if this char sequence is shorter. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.take(8)) // <<<First println(string.takeLast(8)) // Grade>>> println(string.takeWhile { !it.isLetter() }) // <<< println(string.takeLastWhile { !it.isLetter() }) // >>> //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](take#kotlin.text%24take(kotlin.CharSequence,%20kotlin.Int)/n) is negative. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.take(n: Int): String ``` Returns a string containing the first [n](take#kotlin.text%24take(kotlin.String,%20kotlin.Int)/n) characters from this string, or the entire string if this string is shorter. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.take(8)) // <<<First println(string.takeLast(8)) // Grade>>> println(string.takeWhile { !it.isLetter() }) // <<< println(string.takeLastWhile { !it.isLetter() }) // >>> //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](take#kotlin.text%24take(kotlin.String,%20kotlin.Int)/n) is negative. kotlin last last ==== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.last(): Char ``` Returns the last character. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "Kotlin 1.4.0" println(string.last()) // 0 println(string.last { it.isLetter() }) // n println(string.lastOrNull { it > 'z' }) // null // string.last { it > 'z' } // will fail val emptyString = "" println(emptyString.lastOrNull()) // null // emptyString.last() // will fail //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.last(     predicate: (Char) -> Boolean ): Char ``` Returns the last character matching the given [predicate](last#kotlin.text%24last(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "Kotlin 1.4.0" println(string.last()) // 0 println(string.last { it.isLetter() }) // n println(string.lastOrNull { it > 'z' }) // null // string.last { it > 'z' } // will fail val emptyString = "" println(emptyString.lastOrNull()) // null // emptyString.last() // will fail //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if no such character is found.
programming_docs
kotlin maxOfWithOrNull maxOfWithOrNull =============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [maxOfWithOrNull](max-of-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <R> CharSequence.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> R ): R? ``` Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.text%24maxOfWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.text%24maxOfWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.maxOfWithOrNull.R)))/selector) function applied to each character in the char sequence or `null` if there are no characters. kotlin Package kotlin.text Package kotlin.text =================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) Functions for working with text and regular expressions. Types ----- #### [Appendable](-appendable/index) An object to which char sequences and values can be appended. **Platform and version requirements:** JS (1.1) ``` interface Appendable ``` **Platform and version requirements:** JVM (1.1) ``` typealias Appendable = Appendable ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [CharCategory](-char-category/index) Represents the character general category in the Unicode specification. ``` enum class CharCategory ``` **Platform and version requirements:** JVM (1.0) #### [CharDirectionality](-char-directionality/index) Represents the Unicode directionality of a character. Character directionality is used to calculate the visual ordering of text. ``` enum class CharDirectionality ``` **Platform and version requirements:** JVM (1.0) #### [Charsets](-charsets/index) Constant definitions for the standard [charsets](https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html). These charsets are guaranteed to be available on every implementation of the Java platform. ``` object Charsets ``` #### [MatchGroup](-match-group/index) Represents the results from a single capturing group within a MatchResult of [Regex](-regex/index#kotlin.text.Regex). **Platform and version requirements:** ``` class MatchGroup ``` **Platform and version requirements:** JVM (1.0), JS (1.1) ``` data class MatchGroup ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MatchGroupCollection](-match-group-collection/index) Represents a collection of captured groups in a single match of a regular expression. ``` interface MatchGroupCollection : Collection<MatchGroup?> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [MatchNamedGroupCollection](-match-named-group-collection/index) Extends [MatchGroupCollection](-match-group-collection/index) by introducing a way to get matched groups by name, when regex supports it. ``` interface MatchNamedGroupCollection : MatchGroupCollection ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MatchResult](-match-result/index) Represents the results from a single regular expression match. ``` interface MatchResult ``` #### [Regex](-regex/index) Represents a compiled regular expression. Provides functions to match strings in text with a pattern, replace the found occurrences and split text around matches. **Platform and version requirements:** JS (1.1) ``` class Regex ``` **Platform and version requirements:** JVM (1.0) ``` class Regex : Serializable ``` #### [RegexOption](-regex-option/index) Provides enumeration values to use to set regular expression options. **Platform and version requirements:** JS (1.1) ``` enum class RegexOption ``` **Platform and version requirements:** JVM (1.0) ``` enum class RegexOption : FlagEnum ``` #### [StringBuilder](-string-builder/index) A mutable sequence of characters. **Platform and version requirements:** JS (1.1) ``` class StringBuilder : Appendable, CharSequence ``` **Platform and version requirements:** JVM (1.1) ``` typealias StringBuilder = StringBuilder ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Typography](-typography/index) Defines names for Unicode symbols used in proper Typography. ``` object Typography ``` Exceptions ---------- #### [CharacterCodingException](-character-coding-exception/index) The exception thrown when a character encoding or decoding error occurs. **Platform and version requirements:** JS (1.4), Native (1.3) ``` open class CharacterCodingException : Exception ``` **Platform and version requirements:** JVM (1.4) ``` typealias CharacterCodingException = CharacterCodingException ``` Extensions for External Classes ------------------------------- **Platform and version requirements:** JVM (1.0) #### [java.lang.Appendable](java.lang.-appendable/index) **Platform and version requirements:** JVM (1.0) #### [java.lang.StringBuilder](java.lang.-string-builder/index) **Platform and version requirements:** JVM (1.0) #### [java.util.regex.Pattern](java.util.regex.-pattern/index) Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0) #### <category> Returns the Unicode general category of this character. ``` val Char.category: CharCategory ``` **Platform and version requirements:** JVM (1.0) #### <directionality> Returns the Unicode directionality property for the given character. ``` val Char.directionality: CharDirectionality ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <indices> Returns the range of valid character indices for this char sequence. ``` val CharSequence.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](last-index) Returns the index of the last character in the char sequence or -1 if it is empty. ``` val CharSequence.lastIndex: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <all> Returns `true` if all characters match the given [predicate](all#kotlin.text%24all(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.all(predicate: (Char) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <any> Returns `true` if char sequence has at least one character. ``` fun CharSequence.any(): Boolean ``` Returns `true` if at least one character matches the given [predicate](any#kotlin.text%24any(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.any(predicate: (Char) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <append> Appends all arguments to the given [Appendable](-appendable/index#kotlin.text.Appendable). ``` fun <T : Appendable> T.append(vararg value: CharSequence?): T ``` ``` fun StringBuilder.append(obj: Any?): StringBuilder ``` ``` fun StringBuilder.append(     str: CharArray,     offset: Int,     len: Int ): StringBuilder ``` Appends all arguments to the given StringBuilder. ``` fun StringBuilder.append(     vararg value: String? ): StringBuilder ``` ``` fun StringBuilder.append(vararg value: Any?): StringBuilder ``` #### [appendLine](append-line) Appends a line feed character (`\n`) to this Appendable. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Appendable.appendLine(): Appendable ``` Appends value to the given Appendable and a line feed character (`\n`) after it. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Appendable.appendLine(value: CharSequence?): Appendable ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Appendable.appendLine(value: Char): Appendable ``` Appends a line feed character (`\n`) to this StringBuilder. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(): StringBuilder ``` Appends [value](append-line#kotlin.text%24appendLine(kotlin.text.StringBuilder,%20kotlin.CharSequence?)/value) to this [StringBuilder](-string-builder/index#kotlin.text.StringBuilder), followed by a line feed character (`\n`). **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(     value: CharSequence? ): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: String?): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: Any?): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: CharArray): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: Char): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: Boolean): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Byte): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Short): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Int): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Long): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Float): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Double): StringBuilder ``` **Platform and version requirements:** Native (1.3) #### <appendln> ``` fun StringBuilder.appendln(it: String): StringBuilder ``` ``` fun StringBuilder.appendln(it: Boolean): StringBuilder ``` ``` fun StringBuilder.appendln(it: Byte): StringBuilder ``` ``` fun StringBuilder.appendln(it: Short): StringBuilder ``` ``` fun StringBuilder.appendln(it: Int): StringBuilder ``` ``` fun StringBuilder.appendln(it: Long): StringBuilder ``` ``` fun StringBuilder.appendln(it: Float): StringBuilder ``` ``` fun StringBuilder.appendln(it: Double): StringBuilder ``` ``` fun StringBuilder.appendln(it: Any?): StringBuilder ``` ``` fun StringBuilder.appendln(): StringBuilder ``` #### [appendRange](append-range) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) Appends a subsequence of the specified character sequence [value](append-range#kotlin.text%24appendRange(kotlin.text.appendRange.T,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) to this Appendable and returns this instance. ``` fun <T : Appendable> T.appendRange(     value: CharSequence,     startIndex: Int,     endIndex: Int ): T ``` **Platform and version requirements:** JS (1.4) Appends characters in a subarray of the specified character array [value](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/value) to this string builder and returns this instance. ``` fun StringBuilder.appendRange(     value: CharArray,     startIndex: Int,     endIndex: Int ): StringBuilder ``` **Platform and version requirements:** JS (1.4) Appends a subsequence of the specified character sequence [value](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) to this string builder and returns this instance. ``` fun StringBuilder.appendRange(     value: CharSequence,     startIndex: Int,     endIndex: Int ): StringBuilder ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](as-iterable) Creates an [Iterable](../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original char sequence returning its characters when being iterated. ``` fun CharSequence.asIterable(): Iterable<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asSequence](as-sequence) Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original char sequence returning its characters when being iterated. ``` fun CharSequence.asSequence(): Sequence<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <associate> Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](associate#kotlin.text%24associate(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Pair((kotlin.text.associate.K,%20kotlin.text.associate.V)))))/transform) function applied to characters of the given char sequence. ``` fun <K, V> CharSequence.associate(     transform: (Char) -> Pair<K, V> ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateBy](associate-by) Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing the characters from the given char sequence indexed by the key returned from [keySelector](associate-by#kotlin.text%24associateBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateBy.K)))/keySelector) function applied to each character. ``` fun <K> CharSequence.associateBy(     keySelector: (Char) -> K ): Map<K, Char> ``` Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](associate-by#kotlin.text%24associateBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateBy.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateBy.V)))/valueTransform) and indexed by [keySelector](associate-by#kotlin.text%24associateBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateBy.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateBy.V)))/keySelector) functions applied to characters of the given char sequence. ``` fun <K, V> CharSequence.associateBy(     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): Map<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateByTo](associate-by-to) Populates and returns the [destination](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)))/keySelector) function applied to each character of the given char sequence and value is the character itself. ``` fun <K, M : MutableMap<in K, in Char>> CharSequence.associateByTo(     destination: M,     keySelector: (Char) -> K ): M ``` Populates and returns the [destination](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.V)))/destination) mutable map with key-value pairs, where key is provided by the [keySelector](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](associate-by-to#kotlin.text%24associateByTo(kotlin.CharSequence,%20kotlin.text.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateByTo.V)))/valueTransform) function applied to characters of the given char sequence. ``` fun <K, V, M : MutableMap<in K, in V>> CharSequence.associateByTo(     destination: M,     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [associateTo](associate-to) Populates and returns the [destination](associate-to#kotlin.text%24associateTo(kotlin.CharSequence,%20kotlin.text.associateTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.Pair((kotlin.text.associateTo.K,%20kotlin.text.associateTo.V)))))/destination) mutable map with key-value pairs provided by [transform](associate-to#kotlin.text%24associateTo(kotlin.CharSequence,%20kotlin.text.associateTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.Pair((kotlin.text.associateTo.K,%20kotlin.text.associateTo.V)))))/transform) function applied to each character of the given char sequence. ``` fun <K, V, M : MutableMap<in K, in V>> CharSequence.associateTo(     destination: M,     transform: (Char) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWith](associate-with) Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) where keys are characters from the given char sequence and values are produced by the [valueSelector](associate-with#kotlin.text%24associateWith(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateWith.V)))/valueSelector) function applied to each character. ``` fun <V> CharSequence.associateWith(     valueSelector: (Char) -> V ): Map<Char, V> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [associateWithTo](associate-with-to) Populates and returns the [destination](associate-with-to#kotlin.text%24associateWithTo(kotlin.CharSequence,%20kotlin.text.associateWithTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateWithTo.V)))/destination) mutable map with key-value pairs for each character of the given char sequence, where key is the character itself and value is provided by the [valueSelector](associate-with-to#kotlin.text%24associateWithTo(kotlin.CharSequence,%20kotlin.text.associateWithTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Char, in V>> CharSequence.associateWithTo(     destination: M,     valueSelector: (Char) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [buildString](build-string) Builds new string by populating newly created [StringBuilder](-string-builder/index#kotlin.text.StringBuilder) using provided [builderAction](build-string#kotlin.text%24buildString(kotlin.Function1((kotlin.text.StringBuilder,%20kotlin.Unit)))/builderAction) and then converting it to [String](../kotlin/-string/index#kotlin.String). ``` fun buildString(     builderAction: StringBuilder.() -> Unit ): String ``` Builds new string by populating newly created [StringBuilder](-string-builder/index#kotlin.text.StringBuilder) initialized with the given [capacity](build-string#kotlin.text%24buildString(kotlin.Int,%20kotlin.Function1((kotlin.text.StringBuilder,%20kotlin.Unit)))/capacity) using provided [builderAction](build-string#kotlin.text%24buildString(kotlin.Int,%20kotlin.Function1((kotlin.text.StringBuilder,%20kotlin.Unit)))/builderAction) and then converting it to [String](../kotlin/-string/index#kotlin.String). ``` fun buildString(     capacity: Int,     builderAction: StringBuilder.() -> Unit ): String ``` #### <capitalize> **Platform and version requirements:** JVM (1.4) Returns a copy of this string having its first letter titlecased using the rules of the specified [locale](capitalize#kotlin.text%24capitalize(kotlin.String,%20java.util.Locale)/locale), or the original string if it's empty or already starts with a title case letter. ``` fun String.capitalize(locale: Locale): String ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) Returns a copy of this string having its first letter titlecased using the rules of the default locale, or the original string if it's empty or already starts with a title case letter. ``` fun String.capitalize(): String ``` **Platform and version requirements:** JVM (1.0) #### <charset> Returns a named charset with the given [charsetName](charset#kotlin.text%24charset(kotlin.String)/charsetName) name. ``` fun charset(charsetName: String): Charset ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <chunked> Splits this char sequence into a list of strings each not exceeding the given [size](chunked#kotlin.text%24chunked(kotlin.CharSequence,%20kotlin.Int)/size). ``` fun CharSequence.chunked(size: Int): List<String> ``` Splits this char sequence into several char sequences each not exceeding the given [size](chunked#kotlin.text%24chunked(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.chunked.R)))/size) and applies the given [transform](chunked#kotlin.text%24chunked(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.chunked.R)))/transform) function to an each. ``` fun <R> CharSequence.chunked(     size: Int,     transform: (CharSequence) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [chunkedSequence](chunked-sequence) Splits this char sequence into a sequence of strings each not exceeding the given [size](chunked-sequence#kotlin.text%24chunkedSequence(kotlin.CharSequence,%20kotlin.Int)/size). ``` fun CharSequence.chunkedSequence(size: Int): Sequence<String> ``` Splits this char sequence into several char sequences each not exceeding the given [size](chunked-sequence#kotlin.text%24chunkedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.chunkedSequence.R)))/size) and applies the given [transform](chunked-sequence#kotlin.text%24chunkedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.chunkedSequence.R)))/transform) function to an each. ``` fun <R> CharSequence.chunkedSequence(     size: Int,     transform: (CharSequence) -> R ): Sequence<R> ``` **Platform and version requirements:** JS (1.3) #### <clear> Clears the content of this string builder making it empty and returns this instance. ``` fun StringBuilder.clear(): StringBuilder ``` **Platform and version requirements:** JVM (1.0) #### [codePointAt](code-point-at) Returns the character (Unicode code point) at the specified index. ``` fun String.codePointAt(index: Int): Int ``` **Platform and version requirements:** JVM (1.0) #### [codePointBefore](code-point-before) Returns the character (Unicode code point) before the specified index. ``` fun String.codePointBefore(index: Int): Int ``` **Platform and version requirements:** JVM (1.0) #### [codePointCount](code-point-count) Returns the number of Unicode code points in the specified text range of this String. ``` fun String.codePointCount(     beginIndex: Int,     endIndex: Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [commonPrefixWith](common-prefix-with) Returns the longest string `prefix` such that this char sequence and [other](common-prefix-with#kotlin.text%24commonPrefixWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) char sequence both start with this prefix, taking care not to split surrogate pairs. If this and [other](common-prefix-with#kotlin.text%24commonPrefixWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) have no common prefix, returns the empty string. ``` fun CharSequence.commonPrefixWith(     other: CharSequence,     ignoreCase: Boolean = false ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [commonSuffixWith](common-suffix-with) Returns the longest string `suffix` such that this char sequence and [other](common-suffix-with#kotlin.text%24commonSuffixWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) char sequence both end with this suffix, taking care not to split surrogate pairs. If this and [other](common-suffix-with#kotlin.text%24commonSuffixWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) have no common suffix, returns the empty string. ``` fun CharSequence.commonSuffixWith(     other: CharSequence,     ignoreCase: Boolean = false ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareTo](compare-to) Compares two strings lexicographically, optionally ignoring case differences. ``` fun String.compareTo(     other: String,     ignoreCase: Boolean = false ): Int ``` **Platform and version requirements:** JS (1.1) #### <concat> ``` fun String.concat(str: String): String ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [concatToString](concat-to-string) Concatenates characters in this [CharArray](../kotlin/-char-array/index#kotlin.CharArray) into a String. ``` fun CharArray.concatToString(): String ``` Concatenates characters in this [CharArray](../kotlin/-char-array/index#kotlin.CharArray) or its subrange into a String. ``` fun CharArray.concatToString(     startIndex: Int = 0,     endIndex: Int = this.size ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Returns `true` if this char sequence contains the specified [other](contains#kotlin.text%24contains(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) sequence of characters as a substring. ``` operator fun CharSequence.contains(     other: CharSequence,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this char sequence contains the specified character [char](contains#kotlin.text%24contains(kotlin.CharSequence,%20kotlin.Char,%20kotlin.Boolean)/char). ``` operator fun CharSequence.contains(     char: Char,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this char sequence contains at least one match of the specified regular expression [regex](contains#kotlin.text%24contains(kotlin.CharSequence,%20kotlin.text.Regex)/regex). ``` operator fun CharSequence.contains(regex: Regex): Boolean ``` #### [contentEquals](content-equals) **Platform and version requirements:** JVM (1.0) Returns `true` if this string is equal to the contents of the specified [CharSequence](../kotlin/-char-sequence/index#kotlin.CharSequence), `false` otherwise. ``` fun String.contentEquals(charSequence: CharSequence): Boolean ``` **Platform and version requirements:** JVM (1.0) Returns `true` if this string is equal to the contents of the specified [StringBuffer](https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html), `false` otherwise. ``` fun String.contentEquals(     stringBuilder: StringBuffer ): Boolean ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) Returns `true` if the contents of this char sequence are equal to the contents of the specified [other](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?)/other), i.e. both char sequences contain the same number of the same characters in the same order. ``` infix fun CharSequence?.contentEquals(     other: CharSequence? ): Boolean ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) Returns `true` if the contents of this char sequence are equal to the contents of the specified [other](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?,%20kotlin.Boolean)/other), optionally ignoring case difference. ``` fun CharSequence?.contentEquals(     other: CharSequence?,     ignoreCase: Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <count> Returns the length of this char sequence. ``` fun CharSequence.count(): Int ``` Returns the number of characters matching the given [predicate](count#kotlin.text%24count(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.count(predicate: (Char) -> Boolean): Int ``` #### <decapitalize> **Platform and version requirements:** JVM (1.4) Returns a copy of this string having its first letter lowercased using the rules of the specified [locale](decapitalize#kotlin.text%24decapitalize(kotlin.String,%20java.util.Locale)/locale), or the original string, if it's empty or already starts with a lower case letter. ``` fun String.decapitalize(locale: Locale): String ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter. ``` fun String.decapitalize(): String ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [decodeToString](decode-to-string) Decodes a string from the bytes in UTF-8 encoding in this array. ``` fun ByteArray.decodeToString(): String ``` Decodes a string from the bytes in UTF-8 encoding in this array or its subrange. ``` fun ByteArray.decodeToString(     startIndex: Int = 0,     endIndex: Int = this.size,     throwOnInvalidSequence: Boolean = false ): String ``` **Platform and version requirements:** JS (1.4) #### [deleteAt](delete-at) Removes the character at the specified [index](delete-at#kotlin.text%24deleteAt(kotlin.text.StringBuilder,%20kotlin.Int)/index) from this string builder and returns this instance. ``` fun StringBuilder.deleteAt(index: Int): StringBuilder ``` **Platform and version requirements:** JS (1.4) #### [deleteRange](delete-range) Removes characters in the specified range from this string builder and returns this instance. ``` fun StringBuilder.deleteRange(     startIndex: Int,     endIndex: Int ): StringBuilder ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [digitToChar](digit-to-char) Returns the Char that represents this decimal digit. Throws an exception if this value is not in the range `0..9`. ``` fun Int.digitToChar(): Char ``` Returns the Char that represents this numeric digit value in the specified [radix](digit-to-char#kotlin.text%24digitToChar(kotlin.Int,%20kotlin.Int)/radix). Throws an exception if the [radix](digit-to-char#kotlin.text%24digitToChar(kotlin.Int,%20kotlin.Int)/radix) is not in the range `2..36` or if this value is not in the range `0 until radix`. ``` fun Int.digitToChar(radix: Int): Char ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [digitToInt](digit-to-int) Returns the numeric value of the decimal digit that this Char represents. Throws an exception if this Char is not a valid decimal digit. ``` fun Char.digitToInt(): Int ``` Returns the numeric value of the digit that this Char represents in the specified [radix](digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix). Throws an exception if the [radix](digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix) is not in the range `2..36` or if this Char is not a valid digit in the specified [radix](digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix). ``` fun Char.digitToInt(radix: Int): Int ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [digitToIntOrNull](digit-to-int-or-null) Returns the numeric value of the decimal digit that this Char represents, or `null` if this Char is not a valid decimal digit. ``` fun Char.digitToIntOrNull(): Int? ``` Returns the numeric value of the digit that this Char represents in the specified [radix](digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix), or `null` if this Char is not a valid digit in the specified [radix](digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix). Throws an exception if the [radix](digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix) is not in the range `2..36`. ``` fun Char.digitToIntOrNull(radix: Int): Int? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <drop> Returns a subsequence of this char sequence with the first [n](drop#kotlin.text%24drop(kotlin.CharSequence,%20kotlin.Int)/n) characters removed. ``` fun CharSequence.drop(n: Int): CharSequence ``` Returns a string with the first [n](drop#kotlin.text%24drop(kotlin.String,%20kotlin.Int)/n) characters removed. ``` fun String.drop(n: Int): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](drop-last) Returns a subsequence of this char sequence with the last [n](drop-last#kotlin.text%24dropLast(kotlin.CharSequence,%20kotlin.Int)/n) characters removed. ``` fun CharSequence.dropLast(n: Int): CharSequence ``` Returns a string with the last [n](drop-last#kotlin.text%24dropLast(kotlin.String,%20kotlin.Int)/n) characters removed. ``` fun String.dropLast(n: Int): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](drop-last-while) Returns a subsequence of this char sequence containing all characters except last characters that satisfy the given [predicate](drop-last-while#kotlin.text%24dropLastWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.dropLastWhile(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string containing all characters except last characters that satisfy the given [predicate](drop-last-while#kotlin.text%24dropLastWhile(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun String.dropLastWhile(     predicate: (Char) -> Boolean ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](drop-while) Returns a subsequence of this char sequence containing all characters except first characters that satisfy the given [predicate](drop-while#kotlin.text%24dropWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.dropWhile(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string containing all characters except first characters that satisfy the given [predicate](drop-while#kotlin.text%24dropWhile(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun String.dropWhile(predicate: (Char) -> Boolean): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAt](element-at) Returns a character at the given [index](element-at#kotlin.text%24elementAt(kotlin.CharSequence,%20kotlin.Int)/index) or throws an [IndexOutOfBoundsException](../kotlin/-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) if the [index](element-at#kotlin.text%24elementAt(kotlin.CharSequence,%20kotlin.Int)/index) is out of bounds of this char sequence. ``` fun CharSequence.elementAt(index: Int): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](element-at-or-else) Returns a character at the given [index](element-at-or-else#kotlin.text%24elementAtOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) or the result of calling the [defaultValue](element-at-or-else#kotlin.text%24elementAtOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](element-at-or-else#kotlin.text%24elementAtOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) is out of bounds of this char sequence. ``` fun CharSequence.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](element-at-or-null) Returns a character at the given [index](element-at-or-null#kotlin.text%24elementAtOrNull(kotlin.CharSequence,%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.text%24elementAtOrNull(kotlin.CharSequence,%20kotlin.Int)/index) is out of bounds of this char sequence. ``` fun CharSequence.elementAtOrNull(index: Int): Char? ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [encodeToByteArray](encode-to-byte-array) Encodes this string to an array of bytes in UTF-8 encoding. ``` fun String.encodeToByteArray(): ByteArray ``` Encodes this string or its substring to an array of bytes in UTF-8 encoding. ``` fun String.encodeToByteArray(     startIndex: Int = 0,     endIndex: Int = this.length,     throwOnInvalidSequence: Boolean = false ): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [endsWith](ends-with) Returns `true` if this char sequence ends with the specified character. ``` fun CharSequence.endsWith(     char: Char,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this char sequence ends with the specified suffix. ``` fun CharSequence.endsWith(     suffix: CharSequence,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this string ends with the specified suffix. ``` fun String.endsWith(     suffix: String,     ignoreCase: Boolean = false ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Returns `true` if this character is equal to the [other](equals#kotlin.text%24equals(kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/other) character, optionally ignoring character case. ``` fun Char.equals(     other: Char,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this string is equal to [other](equals#kotlin.text%24equals(kotlin.String?,%20kotlin.String?,%20kotlin.Boolean)/other), optionally ignoring character case. ``` fun String?.equals(     other: String?,     ignoreCase: Boolean = false ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <filter> Returns a char sequence containing only those characters from the original char sequence that match the given [predicate](filter#kotlin.text%24filter(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.filter(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string containing only those characters from the original string that match the given [predicate](filter#kotlin.text%24filter(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun String.filter(predicate: (Char) -> Boolean): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](filter-indexed) Returns a char sequence containing only those characters from the original char sequence that match the given [predicate](filter-indexed#kotlin.text%24filterIndexed(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.filterIndexed(     predicate: (index: Int, Char) -> Boolean ): CharSequence ``` Returns a string containing only those characters from the original string that match the given [predicate](filter-indexed#kotlin.text%24filterIndexed(kotlin.String,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun String.filterIndexed(     predicate: (index: Int, Char) -> Boolean ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](filter-indexed-to) Appends all characters matching the given [predicate](filter-indexed-to#kotlin.text%24filterIndexedTo(kotlin.CharSequence,%20kotlin.text.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](filter-indexed-to#kotlin.text%24filterIndexedTo(kotlin.CharSequence,%20kotlin.text.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/destination). ``` fun <C : Appendable> CharSequence.filterIndexedTo(     destination: C,     predicate: (index: Int, Char) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNot](filter-not) Returns a char sequence containing only those characters from the original char sequence that do not match the given [predicate](filter-not#kotlin.text%24filterNot(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.filterNot(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string containing only those characters from the original string that do not match the given [predicate](filter-not#kotlin.text%24filterNot(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun String.filterNot(predicate: (Char) -> Boolean): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](filter-not-to) Appends all characters not matching the given [predicate](filter-not-to#kotlin.text%24filterNotTo(kotlin.CharSequence,%20kotlin.text.filterNotTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](filter-not-to#kotlin.text%24filterNotTo(kotlin.CharSequence,%20kotlin.text.filterNotTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/destination). ``` fun <C : Appendable> CharSequence.filterNotTo(     destination: C,     predicate: (Char) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterTo](filter-to) Appends all characters matching the given [predicate](filter-to#kotlin.text%24filterTo(kotlin.CharSequence,%20kotlin.text.filterTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](filter-to#kotlin.text%24filterTo(kotlin.CharSequence,%20kotlin.text.filterTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/destination). ``` fun <C : Appendable> CharSequence.filterTo(     destination: C,     predicate: (Char) -> Boolean ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <find> Returns the first character matching the given [predicate](find#kotlin.text%24find(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if no such character was found. ``` fun CharSequence.find(predicate: (Char) -> Boolean): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findAnyOf](find-any-of) Finds the first occurrence of any of the specified [strings](find-any-of#kotlin.text%24findAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) in this char sequence, starting from the specified [startIndex](find-any-of#kotlin.text%24findAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. ``` fun CharSequence.findAnyOf(     strings: Collection<String>,     startIndex: Int = 0,     ignoreCase: Boolean = false ): Pair<Int, String>? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLast](find-last) Returns the last character matching the given [predicate](find-last#kotlin.text%24findLast(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if no such character was found. ``` fun CharSequence.findLast(     predicate: (Char) -> Boolean ): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [findLastAnyOf](find-last-any-of) Finds the last occurrence of any of the specified [strings](find-last-any-of#kotlin.text%24findLastAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) in this char sequence, starting from the specified [startIndex](find-last-any-of#kotlin.text%24findLastAnyOf(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. ``` fun CharSequence.findLastAnyOf(     strings: Collection<String>,     startIndex: Int = lastIndex,     ignoreCase: Boolean = false ): Pair<Int, String>? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> Returns the first character. ``` fun CharSequence.first(): Char ``` Returns the first character matching the given [predicate](first#kotlin.text%24first(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.first(predicate: (Char) -> Boolean): Char ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOf](first-not-null-of) Returns the first non-null value produced by [transform](first-not-null-of#kotlin.text%24firstNotNullOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.firstNotNullOf.R?)))/transform) function being applied to characters of this char sequence in iteration order, or throws [NoSuchElementException](../kotlin/-no-such-element-exception/index#kotlin.NoSuchElementException) if no non-null value was produced. ``` fun <R : Any> CharSequence.firstNotNullOf(     transform: (Char) -> R? ): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [firstNotNullOfOrNull](first-not-null-of-or-null) Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.text%24firstNotNullOfOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.firstNotNullOfOrNull.R?)))/transform) function being applied to characters of this char sequence in iteration order, or `null` if no non-null value was produced. ``` fun <R : Any> CharSequence.firstNotNullOfOrNull(     transform: (Char) -> R? ): R? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [firstOrNull](first-or-null) Returns the first character, or `null` if the char sequence is empty. ``` fun CharSequence.firstOrNull(): Char? ``` Returns the first character matching the given [predicate](first-or-null#kotlin.text%24firstOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if character was not found. ``` fun CharSequence.firstOrNull(     predicate: (Char) -> Boolean ): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMap](flat-map) Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.text%24flatMap(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMap.R)))))/transform) function being invoked on each character of original char sequence. ``` fun <R> CharSequence.flatMap(     transform: (Char) -> Iterable<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexed](flat-map-indexed) Returns a single list of all elements yielded from results of [transform](flat-map-indexed#kotlin.text%24flatMapIndexed(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMapIndexed.R)))))/transform) function being invoked on each character and its index in the original char sequence. ``` fun <R> CharSequence.flatMapIndexed(     transform: (index: Int, Char) -> Iterable<R> ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [flatMapIndexedTo](flat-map-indexed-to) Appends all elements yielded from results of [transform](flat-map-indexed-to#kotlin.text%24flatMapIndexedTo(kotlin.CharSequence,%20kotlin.text.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMapIndexedTo.R)))))/transform) function being invoked on each character and its index in the original char sequence, to the given [destination](flat-map-indexed-to#kotlin.text%24flatMapIndexedTo(kotlin.CharSequence,%20kotlin.text.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> CharSequence.flatMapIndexedTo(     destination: C,     transform: (index: Int, Char) -> Iterable<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [flatMapTo](flat-map-to) Appends all elements yielded from results of [transform](flat-map-to#kotlin.text%24flatMapTo(kotlin.CharSequence,%20kotlin.text.flatMapTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMapTo.R)))))/transform) function being invoked on each character of original char sequence, to the given [destination](flat-map-to#kotlin.text%24flatMapTo(kotlin.CharSequence,%20kotlin.text.flatMapTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> CharSequence.flatMapTo(     destination: C,     transform: (Char) -> Iterable<R> ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <fold> Accumulates value starting with [initial](fold#kotlin.text%24fold(kotlin.CharSequence,%20kotlin.text.fold.R,%20kotlin.Function2((kotlin.text.fold.R,%20kotlin.Char,%20)))/initial) value and applying [operation](fold#kotlin.text%24fold(kotlin.CharSequence,%20kotlin.text.fold.R,%20kotlin.Function2((kotlin.text.fold.R,%20kotlin.Char,%20)))/operation) from left to right to current accumulator value and each character. ``` fun <R> CharSequence.fold(     initial: R,     operation: (acc: R, Char) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldIndexed](fold-indexed) Accumulates value starting with [initial](fold-indexed#kotlin.text%24foldIndexed(kotlin.CharSequence,%20kotlin.text.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.foldIndexed.R,%20kotlin.Char,%20)))/initial) value and applying [operation](fold-indexed#kotlin.text%24foldIndexed(kotlin.CharSequence,%20kotlin.text.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.foldIndexed.R,%20kotlin.Char,%20)))/operation) from left to right to current accumulator value and each character with its index in the original char sequence. ``` fun <R> CharSequence.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRight](fold-right) Accumulates value starting with [initial](fold-right#kotlin.text%24foldRight(kotlin.CharSequence,%20kotlin.text.foldRight.R,%20kotlin.Function2((kotlin.Char,%20kotlin.text.foldRight.R,%20)))/initial) value and applying [operation](fold-right#kotlin.text%24foldRight(kotlin.CharSequence,%20kotlin.text.foldRight.R,%20kotlin.Function2((kotlin.Char,%20kotlin.text.foldRight.R,%20)))/operation) from right to left to each character and current accumulator value. ``` fun <R> CharSequence.foldRight(     initial: R,     operation: (Char, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [foldRightIndexed](fold-right-indexed) Accumulates value starting with [initial](fold-right-indexed#kotlin.text%24foldRightIndexed(kotlin.CharSequence,%20kotlin.text.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20kotlin.text.foldRightIndexed.R,%20)))/initial) value and applying [operation](fold-right-indexed#kotlin.text%24foldRightIndexed(kotlin.CharSequence,%20kotlin.text.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20kotlin.text.foldRightIndexed.R,%20)))/operation) from right to left to each character with its index in the original char sequence and current accumulator value. ``` fun <R> CharSequence.foldRightIndexed(     initial: R,     operation: (index: Int, Char, acc: R) -> R ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEach](for-each) Performs the given [action](for-each#kotlin.text%24forEach(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Unit)))/action) on each character. ``` fun CharSequence.forEach(action: (Char) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [forEachIndexed](for-each-indexed) Performs the given [action](for-each-indexed#kotlin.text%24forEachIndexed(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Unit)))/action) on each character, providing sequential index with the character. ``` fun CharSequence.forEachIndexed(     action: (index: Int, Char) -> Unit) ``` **Platform and version requirements:** JVM (1.0) #### <format> Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the default locale. ``` fun String.format(vararg args: Any?): String ``` Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. ``` fun String.format(locale: Locale, vararg args: Any?): String ``` Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. If [locale](format#kotlin.text%24format(kotlin.String,%20java.util.Locale?,%20kotlin.Array((kotlin.Any?)))/locale) is `null` then no localization is applied. ``` fun String.format(locale: Locale?, vararg args: Any?): String ``` **Platform and version requirements:** JVM (1.2), JRE8 (1.2), JS (1.2) #### <get> Returns a named group with the specified [name](get#kotlin.text%24get(kotlin.text.MatchGroupCollection,%20kotlin.String)/name). ``` operator fun MatchGroupCollection.get(     name: String ): MatchGroup? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrElse](get-or-else) Returns a character at the given [index](get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) or the result of calling the [defaultValue](get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) is out of bounds of this char sequence. ``` fun CharSequence.getOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](get-or-null) Returns a character at the given [index](get-or-null#kotlin.text%24getOrNull(kotlin.CharSequence,%20kotlin.Int)/index) or `null` if the [index](get-or-null#kotlin.text%24getOrNull(kotlin.CharSequence,%20kotlin.Int)/index) is out of bounds of this char sequence. ``` fun CharSequence.getOrNull(index: Int): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupBy](group-by) Groups characters of the original char sequence by the key returned by the given [keySelector](group-by#kotlin.text%24groupBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.K)))/keySelector) function applied to each character and returns a map where each group key is associated with a list of corresponding characters. ``` fun <K> CharSequence.groupBy(     keySelector: (Char) -> K ): Map<K, List<Char>> ``` Groups values returned by the [valueTransform](group-by#kotlin.text%24groupBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.V)))/valueTransform) function applied to each character of the original char sequence by the key returned by the given [keySelector](group-by#kotlin.text%24groupBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.V)))/keySelector) function applied to the character and returns a map where each group key is associated with a list of corresponding values. ``` fun <K, V> CharSequence.groupBy(     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): Map<K, List<V>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [groupByTo](group-by-to) Groups characters of the original char sequence by the key returned by the given [keySelector](group-by-to#kotlin.text%24groupByTo(kotlin.CharSequence,%20kotlin.text.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupByTo.K)))/keySelector) function applied to each character and puts to the [destination](group-by-to#kotlin.text%24groupByTo(kotlin.CharSequence,%20kotlin.text.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupByTo.K)))/destination) map each group key associated with a list of corresponding characters. ``` fun <K, M : MutableMap<in K, MutableList<Char>>> CharSequence.groupByTo(     destination: M,     keySelector: (Char) -> K ): M ``` Groups values returned by the [valueTransform](group-by-to#kotlin.text%24groupByTo(kotlin.CharSequence,%20kotlin.text.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupByTo.V)))/valueTransform) function applied to each character of the original char sequence by the key returned by the given [keySelector](group-by-to#kotlin.text%24groupByTo(kotlin.CharSequence,%20kotlin.text.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupByTo.V)))/keySelector) function applied to the character and puts to the [destination](group-by-to#kotlin.text%24groupByTo(kotlin.CharSequence,%20kotlin.text.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupByTo.V)))/destination) map each group key associated with a list of corresponding values. ``` fun <K, V, M : MutableMap<in K, MutableList<V>>> CharSequence.groupByTo(     destination: M,     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): M ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [groupingBy](grouping-by) Creates a [Grouping](../kotlin.collections/-grouping/index) source from a char sequence to be used later with one of group-and-fold operations using the specified [keySelector](grouping-by#kotlin.text%24groupingBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupingBy.K)))/keySelector) function to extract a key from each character. ``` fun <K> CharSequence.groupingBy(     keySelector: (Char) -> K ): Grouping<Char, K> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hasSurrogatePairAt](has-surrogate-pair-at) Returns `true` if this CharSequence has Unicode surrogate pair at the specified [index](has-surrogate-pair-at#kotlin.text%24hasSurrogatePairAt(kotlin.CharSequence,%20kotlin.Int)/index). ``` fun CharSequence.hasSurrogatePairAt(index: Int): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifBlank](if-blank) Returns this char sequence if it is not empty and doesn't consist solely of whitespace characters, or the result of calling [defaultValue](if-blank#kotlin.text%24ifBlank(kotlin.text.ifBlank.C,%20kotlin.Function0((kotlin.text.ifBlank.R)))/defaultValue) function otherwise. ``` fun <C, R> C.ifBlank(     defaultValue: () -> R ): R where C : CharSequence, C : R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ifEmpty](if-empty) Returns this char sequence if it's not empty or the result of calling [defaultValue](if-empty#kotlin.text%24ifEmpty(kotlin.text.ifEmpty.C,%20kotlin.Function0((kotlin.text.ifEmpty.R)))/defaultValue) function if the char sequence is empty. ``` fun <C, R> C.ifEmpty(     defaultValue: () -> R ): R where C : CharSequence, C : R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](index-of) Returns the index within this string of the first occurrence of the specified character, starting from the specified [startIndex](index-of#kotlin.text%24indexOf(kotlin.CharSequence,%20kotlin.Char,%20kotlin.Int,%20kotlin.Boolean)/startIndex). ``` fun CharSequence.indexOf(     char: Char,     startIndex: Int = 0,     ignoreCase: Boolean = false ): Int ``` Returns the index within this char sequence of the first occurrence of the specified [string](index-of#kotlin.text%24indexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/string), starting from the specified [startIndex](index-of#kotlin.text%24indexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/startIndex). ``` fun CharSequence.indexOf(     string: String,     startIndex: Int = 0,     ignoreCase: Boolean = false ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfAny](index-of-any) Finds the index of the first occurrence of any of the specified [chars](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/chars) in this char sequence, starting from the specified [startIndex](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. ``` fun CharSequence.indexOfAny(     chars: CharArray,     startIndex: Int = 0,     ignoreCase: Boolean = false ): Int ``` Finds the index of the first occurrence of any of the specified [strings](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) in this char sequence, starting from the specified [startIndex](index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. ``` fun CharSequence.indexOfAny(     strings: Collection<String>,     startIndex: Int = 0,     ignoreCase: Boolean = false ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfFirst](index-of-first) Returns index of the first character matching the given [predicate](index-of-first#kotlin.text%24indexOfFirst(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or -1 if the char sequence does not contain such character. ``` fun CharSequence.indexOfFirst(     predicate: (Char) -> Boolean ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOfLast](index-of-last) Returns index of the last character matching the given [predicate](index-of-last#kotlin.text%24indexOfLast(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or -1 if the char sequence does not contain such character. ``` fun CharSequence.indexOfLast(     predicate: (Char) -> Boolean ): Int ``` **Platform and version requirements:** JS (1.4) #### [insertRange](insert-range) Inserts characters in a subarray of the specified character array [value](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/value) into this string builder at the specified [index](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/index) and returns this instance. ``` fun StringBuilder.insertRange(     index: Int,     value: CharArray,     startIndex: Int,     endIndex: Int ): StringBuilder ``` Inserts characters in a subsequence of the specified character sequence [value](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) into this string builder at the specified [index](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/index) and returns this instance. ``` fun StringBuilder.insertRange(     index: Int,     value: CharSequence,     startIndex: Int,     endIndex: Int ): StringBuilder ``` **Platform and version requirements:** JVM (1.0) #### <intern> Returns a canonical representation for this string object. ``` fun String.intern(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isBlank](is-blank) Returns `true` if this string is empty or consists solely of whitespace characters. ``` fun CharSequence.isBlank(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [isDefined](is-defined) Returns `true` if this character (Unicode code point) is defined in Unicode. ``` fun Char.isDefined(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [isDigit](is-digit) Returns `true` if this character is a digit. ``` fun Char.isDigit(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Returns `true` if this char sequence is empty (contains no characters). ``` fun CharSequence.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isHighSurrogate](is-high-surrogate) Returns `true` if this character is a Unicode high-surrogate code unit (also known as leading-surrogate code unit). ``` fun Char.isHighSurrogate(): Boolean ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### [isIdentifierIgnorable](is-identifier-ignorable) Returns `true` if this character (Unicode code point) should be regarded as an ignorable character in a Java identifier or a Unicode identifier. ``` fun Char.isIdentifierIgnorable(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isISOControl](is-i-s-o-control) Returns `true` if this character is an ISO control character. ``` fun Char.isISOControl(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [isJavaIdentifierPart](is-java-identifier-part) Returns `true` if this character (Unicode code point) may be part of a Java identifier as other than the first character. ``` fun Char.isJavaIdentifierPart(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [isJavaIdentifierStart](is-java-identifier-start) Returns `true` if this character is permissible as the first character in a Java identifier. ``` fun Char.isJavaIdentifierStart(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [isLetter](is-letter) Returns `true` if this character is a letter. ``` fun Char.isLetter(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [isLetterOrDigit](is-letter-or-digit) Returns `true` if this character is a letter or digit. ``` fun Char.isLetterOrDigit(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [isLowerCase](is-lower-case) Returns `true` if this character is lower case. ``` fun Char.isLowerCase(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isLowSurrogate](is-low-surrogate) Returns `true` if this character is a Unicode low-surrogate code unit (also known as trailing-surrogate code unit). ``` fun Char.isLowSurrogate(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotBlank](is-not-blank) Returns `true` if this char sequence is not empty and contains some characters except of whitespace characters. ``` fun CharSequence.isNotBlank(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](is-not-empty) Returns `true` if this char sequence is not empty. ``` fun CharSequence.isNotEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNullOrBlank](is-null-or-blank) Returns `true` if this nullable char sequence is either `null` or empty or consists solely of whitespace characters. ``` fun CharSequence?.isNullOrBlank(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNullOrEmpty](is-null-or-empty) Returns `true` if this nullable char sequence is either `null` or empty. ``` fun CharSequence?.isNullOrEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isSurrogate](is-surrogate) Returns `true` if this character is a Unicode surrogate code unit. ``` fun Char.isSurrogate(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [isTitleCase](is-title-case) Returns `true` if this character is a title case letter. ``` fun Char.isTitleCase(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [isUpperCase](is-upper-case) Returns `true` if this character is upper case. ``` fun Char.isUpperCase(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [isWhitespace](is-whitespace) Determines whether a character is whitespace according to the Unicode standard. Returns `true` if the character is whitespace. ``` fun Char.isWhitespace(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Iterator for characters of the given char sequence. ``` operator fun CharSequence.iterator(): CharIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> Returns the last character. ``` fun CharSequence.last(): Char ``` Returns the last character matching the given [predicate](last#kotlin.text%24last(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.last(predicate: (Char) -> Boolean): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOf](last-index-of) Returns the index within this char sequence of the last occurrence of the specified character, starting from the specified [startIndex](last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.Char,%20kotlin.Int,%20kotlin.Boolean)/startIndex). ``` fun CharSequence.lastIndexOf(     char: Char,     startIndex: Int = lastIndex,     ignoreCase: Boolean = false ): Int ``` Returns the index within this char sequence of the last occurrence of the specified [string](last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/string), starting from the specified [startIndex](last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/startIndex). ``` fun CharSequence.lastIndexOf(     string: String,     startIndex: Int = lastIndex,     ignoreCase: Boolean = false ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndexOfAny](last-index-of-any) Finds the index of the last occurrence of any of the specified [chars](last-index-of-any#kotlin.text%24lastIndexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/chars) in this char sequence, starting from the specified [startIndex](last-index-of-any#kotlin.text%24lastIndexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. ``` fun CharSequence.lastIndexOfAny(     chars: CharArray,     startIndex: Int = lastIndex,     ignoreCase: Boolean = false ): Int ``` Finds the index of the last occurrence of any of the specified [strings](last-index-of-any#kotlin.text%24lastIndexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/strings) in this char sequence, starting from the specified [startIndex](last-index-of-any#kotlin.text%24lastIndexOfAny(kotlin.CharSequence,%20kotlin.collections.Collection((kotlin.String)),%20kotlin.Int,%20kotlin.Boolean)/startIndex) and optionally ignoring the case. ``` fun CharSequence.lastIndexOfAny(     strings: Collection<String>,     startIndex: Int = lastIndex,     ignoreCase: Boolean = false ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastOrNull](last-or-null) Returns the last character, or `null` if the char sequence is empty. ``` fun CharSequence.lastOrNull(): Char? ``` Returns the last character matching the given [predicate](last-or-null#kotlin.text%24lastOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if no such character was found. ``` fun CharSequence.lastOrNull(     predicate: (Char) -> Boolean ): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <lines> Splits this char sequence to a list of lines delimited by any of the following character sequences: CRLF, LF or CR. ``` fun CharSequence.lines(): List<String> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lineSequence](line-sequence) Splits this char sequence to a sequence of lines delimited by any of the following character sequences: CRLF, LF or CR. ``` fun CharSequence.lineSequence(): Sequence<String> ``` #### <lowercase> **Platform and version requirements:** JVM (1.5) Converts this character to lower case using Unicode mapping rules of the specified [locale](lowercase#kotlin.text%24lowercase(kotlin.Char,%20java.util.Locale)/locale). ``` fun Char.lowercase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.5) Returns a copy of this string converted to lower case using the rules of the specified [locale](lowercase#kotlin.text%24lowercase(kotlin.String,%20java.util.Locale)/locale). ``` fun String.lowercase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5) Converts this character to lower case using Unicode mapping rules of the invariant locale. ``` fun Char.lowercase(): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) Returns a copy of this string converted to lower case using Unicode mapping rules of the invariant locale. ``` fun String.lowercase(): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5) #### [lowercaseChar](lowercase-char) Converts this character to lower case using Unicode mapping rules of the invariant locale. ``` fun Char.lowercaseChar(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <map> Returns a list containing the results of applying the given [transform](map#kotlin.text%24map(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.map.R)))/transform) function to each character in the original char sequence. ``` fun <R> CharSequence.map(transform: (Char) -> R): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexed](map-indexed) Returns a list containing the results of applying the given [transform](map-indexed#kotlin.text%24mapIndexed(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexed.R)))/transform) function to each character and its index in the original char sequence. ``` fun <R> CharSequence.mapIndexed(     transform: (index: Int, Char) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNull](map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](map-indexed-not-null#kotlin.text%24mapIndexedNotNull(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexedNotNull.R?)))/transform) function to each character and its index in the original char sequence. ``` fun <R : Any> CharSequence.mapIndexedNotNull(     transform: (index: Int, Char) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedNotNullTo](map-indexed-not-null-to) Applies the given [transform](map-indexed-not-null-to#kotlin.text%24mapIndexedNotNullTo(kotlin.CharSequence,%20kotlin.text.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexedNotNullTo.R?)))/transform) function to each character and its index in the original char sequence and appends only the non-null results to the given [destination](map-indexed-not-null-to#kotlin.text%24mapIndexedNotNullTo(kotlin.CharSequence,%20kotlin.text.mapIndexedNotNullTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexedNotNullTo.R?)))/destination). ``` fun <R : Any, C : MutableCollection<in R>> CharSequence.mapIndexedNotNullTo(     destination: C,     transform: (index: Int, Char) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapIndexedTo](map-indexed-to) Applies the given [transform](map-indexed-to#kotlin.text%24mapIndexedTo(kotlin.CharSequence,%20kotlin.text.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexedTo.R)))/transform) function to each character and its index in the original char sequence and appends the results to the given [destination](map-indexed-to#kotlin.text%24mapIndexedTo(kotlin.CharSequence,%20kotlin.text.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(     destination: C,     transform: (index: Int, Char) -> R ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNull](map-not-null) Returns a list containing only the non-null results of applying the given [transform](map-not-null#kotlin.text%24mapNotNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.mapNotNull.R?)))/transform) function to each character in the original char sequence. ``` fun <R : Any> CharSequence.mapNotNull(     transform: (Char) -> R? ): List<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapNotNullTo](map-not-null-to) Applies the given [transform](map-not-null-to#kotlin.text%24mapNotNullTo(kotlin.CharSequence,%20kotlin.text.mapNotNullTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.text.mapNotNullTo.R?)))/transform) function to each character in the original char sequence and appends only the non-null results to the given [destination](map-not-null-to#kotlin.text%24mapNotNullTo(kotlin.CharSequence,%20kotlin.text.mapNotNullTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.text.mapNotNullTo.R?)))/destination). ``` fun <R : Any, C : MutableCollection<in R>> CharSequence.mapNotNullTo(     destination: C,     transform: (Char) -> R? ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [mapTo](map-to) Applies the given [transform](map-to#kotlin.text%24mapTo(kotlin.CharSequence,%20kotlin.text.mapTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.text.mapTo.R)))/transform) function to each character of the original char sequence and appends the results to the given [destination](map-to#kotlin.text%24mapTo(kotlin.CharSequence,%20kotlin.text.mapTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.text.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> CharSequence.mapTo(     destination: C,     transform: (Char) -> R ): C ``` **Platform and version requirements:** JS (1.1) #### <match> ``` fun String.match(regex: String): Array<String>? ``` #### <matches> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Returns `true` if this char sequence matches the given regular expression. ``` infix fun CharSequence.matches(regex: Regex): Boolean ``` **Platform and version requirements:** JS (1.1) ``` fun String.matches(regex: String): Boolean ``` #### <max> Returns the largest character. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun CharSequence.max(): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun CharSequence.max(): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [maxBy](max-by) Returns the first character yielding the largest value of the given function. ``` fun <R : Comparable<R>> any_iterable<R>.maxBy(     selector: (Char) -> R ): Char ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](max-by-or-null) Returns the first character yielding the largest value of the given function or `null` if there are no characters. ``` fun <R : Comparable<R>> CharSequence.maxByOrNull(     selector: (Char) -> R ): Char? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOf](max-of) Returns the largest value among all values produced by [selector](max-of#kotlin.text%24maxOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence. ``` fun <R : Comparable<R>> any_iterable<R>.maxOf(     selector: (Char) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfOrNull](max-of-or-null) Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.text%24maxOfOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence or `null` if there are no characters. ``` fun <R : Comparable<R>> any_iterable<R>.maxOfOrNull(     selector: (Char) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWith](max-of-with) Returns the largest value according to the provided [comparator](max-of-with#kotlin.text%24maxOfWith(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.maxOfWith.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.maxOfWith.R)))/comparator) among all values produced by [selector](max-of-with#kotlin.text%24maxOfWith(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.maxOfWith.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.maxOfWith.R)))/selector) function applied to each character in the char sequence. ``` fun <R> CharSequence.maxOfWith(     comparator: Comparator<in R>,     selector: (Char) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOfWithOrNull](max-of-with-or-null) Returns the largest value according to the provided [comparator](max-of-with-or-null#kotlin.text%24maxOfWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](max-of-with-or-null#kotlin.text%24maxOfWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.maxOfWithOrNull.R)))/selector) function applied to each character in the char sequence or `null` if there are no characters. ``` fun <R> CharSequence.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxOrNull](max-or-null) Returns the largest character or `null` if there are no characters. ``` fun CharSequence.maxOrNull(): Char? ``` #### [maxWith](max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first character having the largest value according to the provided [comparator](max-with#kotlin.text%24maxWith(kotlin.CharSequence,%20kotlin.Comparator((kotlin.Char)))/comparator). ``` fun CharSequence.maxWith(     comparator: Comparator<in Char> ): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun CharSequence.maxWith(     comparator: Comparator<in Char> ): Char? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxWithOrNull](max-with-or-null) Returns the first character having the largest value according to the provided [comparator](max-with-or-null#kotlin.text%24maxWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.Char)))/comparator) or `null` if there are no characters. ``` fun CharSequence.maxWithOrNull(     comparator: Comparator<in Char> ): Char? ``` #### <min> Returns the smallest character. **Platform and version requirements:** JS (1.7), Native (1.7) ``` fun CharSequence.min(): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun CharSequence.min(): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [minBy](min-by) Returns the first character yielding the smallest value of the given function. ``` fun <R : Comparable<R>> any_iterable<R>.minBy(     selector: (Char) -> R ): Char ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](min-by-or-null) Returns the first character yielding the smallest value of the given function or `null` if there are no characters. ``` fun <R : Comparable<R>> CharSequence.minByOrNull(     selector: (Char) -> R ): Char? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOf](min-of) Returns the smallest value among all values produced by [selector](min-of#kotlin.text%24minOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence. ``` fun <R : Comparable<R>> any_iterable<R>.minOf(     selector: (Char) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfOrNull](min-of-or-null) Returns the smallest value among all values produced by [selector](min-of-or-null#kotlin.text%24minOfOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence or `null` if there are no characters. ``` fun <R : Comparable<R>> any_iterable<R>.minOfOrNull(     selector: (Char) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWith](min-of-with) Returns the smallest value according to the provided [comparator](min-of-with#kotlin.text%24minOfWith(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.minOfWith.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.minOfWith.R)))/comparator) among all values produced by [selector](min-of-with#kotlin.text%24minOfWith(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.minOfWith.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.minOfWith.R)))/selector) function applied to each character in the char sequence. ``` fun <R> CharSequence.minOfWith(     comparator: Comparator<in R>,     selector: (Char) -> R ): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOfWithOrNull](min-of-with-or-null) Returns the smallest value according to the provided [comparator](min-of-with-or-null#kotlin.text%24minOfWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.minOfWithOrNull.R)))/comparator) among all values produced by [selector](min-of-with-or-null#kotlin.text%24minOfWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.text.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.minOfWithOrNull.R)))/selector) function applied to each character in the char sequence or `null` if there are no characters. ``` fun <R> CharSequence.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> R ): R? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minOrNull](min-or-null) Returns the smallest character or `null` if there are no characters. ``` fun CharSequence.minOrNull(): Char? ``` #### [minWith](min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) Returns the first character having the smallest value according to the provided [comparator](min-with#kotlin.text%24minWith(kotlin.CharSequence,%20kotlin.Comparator((kotlin.Char)))/comparator). ``` fun CharSequence.minWith(     comparator: Comparator<in Char> ): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun CharSequence.minWith(     comparator: Comparator<in Char> ): Char? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minWithOrNull](min-with-or-null) Returns the first character having the smallest value according to the provided [comparator](min-with-or-null#kotlin.text%24minWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.Char)))/comparator) or `null` if there are no characters. ``` fun CharSequence.minWithOrNull(     comparator: Comparator<in Char> ): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <none> Returns `true` if the char sequence has no characters. ``` fun CharSequence.none(): Boolean ``` Returns `true` if no characters match the given [predicate](none#kotlin.text%24none(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.none(predicate: (Char) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [offsetByCodePoints](offset-by-code-points) Returns the index within this string that is offset from the given [index](offset-by-code-points#kotlin.text%24offsetByCodePoints(kotlin.String,%20kotlin.Int,%20kotlin.Int)/index) by [codePointOffset](offset-by-code-points#kotlin.text%24offsetByCodePoints(kotlin.String,%20kotlin.Int,%20kotlin.Int)/codePointOffset) code points. ``` fun String.offsetByCodePoints(     index: Int,     codePointOffset: Int ): Int ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [onEach](on-each) Performs the given [action](on-each#kotlin.text%24onEach(kotlin.text.onEach.S,%20kotlin.Function1((kotlin.Char,%20kotlin.Unit)))/action) on each character and returns the char sequence itself afterwards. ``` fun <S : CharSequence> S.onEach(action: (Char) -> Unit): S ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEachIndexed](on-each-indexed) Performs the given [action](on-each-indexed#kotlin.text%24onEachIndexed(kotlin.text.onEachIndexed.S,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Unit)))/action) on each character, providing sequential index with the character, and returns the char sequence itself afterwards. ``` fun <S : CharSequence> S.onEachIndexed(     action: (index: Int, Char) -> Unit ): S ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [orEmpty](or-empty) Returns the string if it is not `null`, or the empty string otherwise. ``` fun String?.orEmpty(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [padEnd](pad-end) Returns a char sequence with content of this char sequence padded at the end to the specified [length](pad-end#kotlin.text%24padEnd(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/length) with the specified character or space. ``` fun CharSequence.padEnd(     length: Int,     padChar: Char = ' ' ): CharSequence ``` Pads the string to the specified [length](pad-end#kotlin.text%24padEnd(kotlin.String,%20kotlin.Int,%20kotlin.Char)/length) at the end with the specified character or space. ``` fun String.padEnd(length: Int, padChar: Char = ' '): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [padStart](pad-start) Returns a char sequence with content of this char sequence padded at the beginning to the specified [length](pad-start#kotlin.text%24padStart(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/length) with the specified character or space. ``` fun CharSequence.padStart(     length: Int,     padChar: Char = ' ' ): CharSequence ``` Pads the string to the specified [length](pad-start#kotlin.text%24padStart(kotlin.String,%20kotlin.Int,%20kotlin.Char)/length) at the beginning with the specified character or space. ``` fun String.padStart(length: Int, padChar: Char = ' '): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <partition> Splits the original char sequence into pair of char sequences, where *first* char sequence contains characters for which [predicate](partition#kotlin.text%24partition(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* char sequence contains characters for which [predicate](partition#kotlin.text%24partition(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun CharSequence.partition(     predicate: (Char) -> Boolean ): Pair<CharSequence, CharSequence> ``` Splits the original string into pair of strings, where *first* string contains characters for which [predicate](partition#kotlin.text%24partition(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* string contains characters for which [predicate](partition#kotlin.text%24partition(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun String.partition(     predicate: (Char) -> Boolean ): Pair<String, String> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Concatenates this Char and a String. ``` operator fun Char.plus(other: String): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [prependIndent](prepend-indent) Prepends [indent](prepend-indent#kotlin.text%24prependIndent(kotlin.String,%20kotlin.String)/indent) to every line of the original string. ``` fun String.prependIndent(indent: String = " "): String ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <random> Returns a random character from this char sequence. ``` fun CharSequence.random(): Char ``` Returns a random character from this char sequence using the specified source of randomness. ``` fun CharSequence.random(random: Random): Char ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](random-or-null) Returns a random character from this char sequence, or `null` if this char sequence is empty. ``` fun CharSequence.randomOrNull(): Char? ``` Returns a random character from this char sequence using the specified source of randomness, or `null` if this char sequence is empty. ``` fun CharSequence.randomOrNull(random: Random): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <reduce> Accumulates value starting with the first character and applying [operation](reduce#kotlin.text%24reduce(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each character. ``` fun CharSequence.reduce(     operation: (acc: Char, Char) -> Char ): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceIndexed](reduce-indexed) Accumulates value starting with the first character and applying [operation](reduce-indexed#kotlin.text%24reduceIndexed(kotlin.CharSequence,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each character with its index in the original char sequence. ``` fun CharSequence.reduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): Char ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceIndexedOrNull](reduce-indexed-or-null) Accumulates value starting with the first character and applying [operation](reduce-indexed-or-null#kotlin.text%24reduceIndexedOrNull(kotlin.CharSequence,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each character with its index in the original char sequence. ``` fun CharSequence.reduceIndexedOrNull(     operation: (index: Int, acc: Char, Char) -> Char ): Char? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceOrNull](reduce-or-null) Accumulates value starting with the first character and applying [operation](reduce-or-null#kotlin.text%24reduceOrNull(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each character. ``` fun CharSequence.reduceOrNull(     operation: (acc: Char, Char) -> Char ): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRight](reduce-right) Accumulates value starting with the last character and applying [operation](reduce-right#kotlin.text%24reduceRight(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from right to left to each character and current accumulator value. ``` fun CharSequence.reduceRight(     operation: (Char, acc: Char) -> Char ): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduceRightIndexed](reduce-right-indexed) Accumulates value starting with the last character and applying [operation](reduce-right-indexed#kotlin.text%24reduceRightIndexed(kotlin.CharSequence,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from right to left to each character with its index in the original char sequence and current accumulator value. ``` fun CharSequence.reduceRightIndexed(     operation: (index: Int, Char, acc: Char) -> Char ): Char ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightIndexedOrNull](reduce-right-indexed-or-null) Accumulates value starting with the last character and applying [operation](reduce-right-indexed-or-null#kotlin.text%24reduceRightIndexedOrNull(kotlin.CharSequence,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from right to left to each character with its index in the original char sequence and current accumulator value. ``` fun CharSequence.reduceRightIndexedOrNull(     operation: (index: Int, Char, acc: Char) -> Char ): Char? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [reduceRightOrNull](reduce-right-or-null) Accumulates value starting with the last character and applying [operation](reduce-right-or-null#kotlin.text%24reduceRightOrNull(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from right to left to each character and current accumulator value. ``` fun CharSequence.reduceRightOrNull(     operation: (Char, acc: Char) -> Char ): Char? ``` #### [regionMatches](region-matches) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) Returns `true` if the specified range in this char sequence is equal to the specified range in another char sequence. ``` fun CharSequence.regionMatches(     thisOffset: Int,     other: CharSequence,     otherOffset: Int,     length: Int,     ignoreCase: Boolean = false ): Boolean ``` **Platform and version requirements:** JVM (1.0), Native (1.3) Returns `true` if the specified range in this string is equal to the specified range in another string. ``` fun String.regionMatches(     thisOffset: Int,     other: String,     otherOffset: Int,     length: Int,     ignoreCase: Boolean = false ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removePrefix](remove-prefix) If this char sequence starts with the given [prefix](remove-prefix#kotlin.text%24removePrefix(kotlin.CharSequence,%20kotlin.CharSequence)/prefix), returns a new char sequence with the prefix removed. Otherwise, returns a new char sequence with the same characters. ``` fun CharSequence.removePrefix(     prefix: CharSequence ): CharSequence ``` If this string starts with the given [prefix](remove-prefix#kotlin.text%24removePrefix(kotlin.String,%20kotlin.CharSequence)/prefix), returns a copy of this string with the prefix removed. Otherwise, returns this string. ``` fun String.removePrefix(prefix: CharSequence): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeRange](remove-range) Returns a char sequence with content of this char sequence where its part at the given range is removed. ``` fun CharSequence.removeRange(     startIndex: Int,     endIndex: Int ): CharSequence ``` Removes the part of a string at a given range. ``` fun String.removeRange(     startIndex: Int,     endIndex: Int ): String ``` Returns a char sequence with content of this char sequence where its part at the given [range](remove-range#kotlin.text%24removeRange(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) is removed. ``` fun CharSequence.removeRange(range: IntRange): CharSequence ``` Removes the part of a string at the given [range](remove-range#kotlin.text%24removeRange(kotlin.String,%20kotlin.ranges.IntRange)/range). ``` fun String.removeRange(range: IntRange): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeSuffix](remove-suffix) If this char sequence ends with the given [suffix](remove-suffix#kotlin.text%24removeSuffix(kotlin.CharSequence,%20kotlin.CharSequence)/suffix), returns a new char sequence with the suffix removed. Otherwise, returns a new char sequence with the same characters. ``` fun CharSequence.removeSuffix(     suffix: CharSequence ): CharSequence ``` If this string ends with the given [suffix](remove-suffix#kotlin.text%24removeSuffix(kotlin.String,%20kotlin.CharSequence)/suffix), returns a copy of this string with the suffix removed. Otherwise, returns this string. ``` fun String.removeSuffix(suffix: CharSequence): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeSurrounding](remove-surrounding) When this char sequence starts with the given [prefix](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence)/prefix) and ends with the given [suffix](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence)/suffix), returns a new char sequence having both the given [prefix](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence)/prefix) and [suffix](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence)/suffix) removed. Otherwise returns a new char sequence with the same characters. ``` fun CharSequence.removeSurrounding(     prefix: CharSequence,     suffix: CharSequence ): CharSequence ``` Removes from a string both the given [prefix](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence,%20kotlin.CharSequence)/prefix) and [suffix](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence,%20kotlin.CharSequence)/suffix) if and only if it starts with the [prefix](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence,%20kotlin.CharSequence)/prefix) and ends with the [suffix](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence,%20kotlin.CharSequence)/suffix). Otherwise returns this string unchanged. ``` fun String.removeSurrounding(     prefix: CharSequence,     suffix: CharSequence ): String ``` When this char sequence starts with and ends with the given [delimiter](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence)/delimiter), returns a new char sequence having this [delimiter](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence)/delimiter) removed both from the start and end. Otherwise returns a new char sequence with the same characters. ``` fun CharSequence.removeSurrounding(     delimiter: CharSequence ): CharSequence ``` Removes the given [delimiter](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence)/delimiter) string from both the start and the end of this string if and only if it starts with and ends with the [delimiter](remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence)/delimiter). Otherwise returns this string unchanged. ``` fun String.removeSurrounding(delimiter: CharSequence): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <repeat> Returns a string containing this char sequence repeated [n](repeat#kotlin.text%24repeat(kotlin.CharSequence,%20kotlin.Int)/n) times. ``` fun CharSequence.repeat(n: Int): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <replace> Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the given [replacement](replace#kotlin.text%24replace(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/replacement). ``` fun CharSequence.replace(     regex: Regex,     replacement: String ): String ``` Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the result of the given function [transform](replace#kotlin.text%24replace(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.Function1((kotlin.text.MatchResult,%20kotlin.CharSequence)))/transform) that takes [MatchResult](-match-result/index) and returns a string to be used as a replacement for that match. ``` fun CharSequence.replace(     regex: Regex,     transform: (MatchResult) -> CharSequence ): String ``` Returns a new string with all occurrences of [oldChar](replace#kotlin.text%24replace(kotlin.String,%20kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/oldChar) replaced with [newChar](replace#kotlin.text%24replace(kotlin.String,%20kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/newChar). ``` fun String.replace(     oldChar: Char,     newChar: Char,     ignoreCase: Boolean = false ): String ``` Returns a new string obtained by replacing all occurrences of the [oldValue](replace#kotlin.text%24replace(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.Boolean)/oldValue) substring in this string with the specified [newValue](replace#kotlin.text%24replace(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.Boolean)/newValue) string. ``` fun String.replace(     oldValue: String,     newValue: String,     ignoreCase: Boolean = false ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceAfter](replace-after) Replace part of string after the first occurrence of given delimiter with the [replacement](replace-after#kotlin.text%24replaceAfter(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/replacement) string. If the string does not contain the delimiter, returns [missingDelimiterValue](replace-after#kotlin.text%24replaceAfter(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. ``` fun String.replaceAfter(     delimiter: Char,     replacement: String,     missingDelimiterValue: String = this ): String ``` ``` fun String.replaceAfter(     delimiter: String,     replacement: String,     missingDelimiterValue: String = this ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceAfterLast](replace-after-last) Replace part of string after the last occurrence of given delimiter with the [replacement](replace-after-last#kotlin.text%24replaceAfterLast(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.String)/replacement) string. If the string does not contain the delimiter, returns [missingDelimiterValue](replace-after-last#kotlin.text%24replaceAfterLast(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. ``` fun String.replaceAfterLast(     delimiter: String,     replacement: String,     missingDelimiterValue: String = this ): String ``` ``` fun String.replaceAfterLast(     delimiter: Char,     replacement: String,     missingDelimiterValue: String = this ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceBefore](replace-before) Replace part of string before the first occurrence of given delimiter with the [replacement](replace-before#kotlin.text%24replaceBefore(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/replacement) string. If the string does not contain the delimiter, returns [missingDelimiterValue](replace-before#kotlin.text%24replaceBefore(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. ``` fun String.replaceBefore(     delimiter: Char,     replacement: String,     missingDelimiterValue: String = this ): String ``` ``` fun String.replaceBefore(     delimiter: String,     replacement: String,     missingDelimiterValue: String = this ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceBeforeLast](replace-before-last) Replace part of string before the last occurrence of given delimiter with the [replacement](replace-before-last#kotlin.text%24replaceBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/replacement) string. If the string does not contain the delimiter, returns [missingDelimiterValue](replace-before-last#kotlin.text%24replaceBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. ``` fun String.replaceBeforeLast(     delimiter: Char,     replacement: String,     missingDelimiterValue: String = this ): String ``` ``` fun String.replaceBeforeLast(     delimiter: String,     replacement: String,     missingDelimiterValue: String = this ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceFirst](replace-first) Replaces the first occurrence of the given regular expression [regex](replace-first#kotlin.text%24replaceFirst(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/regex) in this char sequence with specified [replacement](replace-first#kotlin.text%24replaceFirst(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/replacement) expression. ``` fun CharSequence.replaceFirst(     regex: Regex,     replacement: String ): String ``` Returns a new string with the first occurrence of [oldChar](replace-first#kotlin.text%24replaceFirst(kotlin.String,%20kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/oldChar) replaced with [newChar](replace-first#kotlin.text%24replaceFirst(kotlin.String,%20kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/newChar). ``` fun String.replaceFirst(     oldChar: Char,     newChar: Char,     ignoreCase: Boolean = false ): String ``` Returns a new string obtained by replacing the first occurrence of the [oldValue](replace-first#kotlin.text%24replaceFirst(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.Boolean)/oldValue) substring in this string with the specified [newValue](replace-first#kotlin.text%24replaceFirst(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.Boolean)/newValue) string. ``` fun String.replaceFirst(     oldValue: String,     newValue: String,     ignoreCase: Boolean = false ): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [replaceFirstChar](replace-first-char) Returns a copy of this string having its first character replaced with the result of the specified [transform](replace-first-char#kotlin.text%24replaceFirstChar(kotlin.String,%20kotlin.Function1((kotlin.Char,%20)))/transform), or the original string if it's empty. ``` fun String.replaceFirstChar(     transform: (Char) -> Char ): String ``` ``` fun String.replaceFirstChar(     transform: (Char) -> CharSequence ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceIndent](replace-indent) Detects a common minimal indent like it does [trimIndent](trim-indent) and replaces it with the specified [newIndent](replace-indent#kotlin.text%24replaceIndent(kotlin.String,%20kotlin.String)/newIndent). ``` fun String.replaceIndent(newIndent: String = ""): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceIndentByMargin](replace-indent-by-margin) Detects indent by [marginPrefix](replace-indent-by-margin#kotlin.text%24replaceIndentByMargin(kotlin.String,%20kotlin.String,%20kotlin.String)/marginPrefix) as it does [trimMargin](trim-margin) and replace it with [newIndent](replace-indent-by-margin#kotlin.text%24replaceIndentByMargin(kotlin.String,%20kotlin.String,%20kotlin.String)/newIndent). ``` fun String.replaceIndentByMargin(     newIndent: String = "",     marginPrefix: String = "|" ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceRange](replace-range) Returns a char sequence with content of this char sequence where its part at the given range is replaced with the [replacement](replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.CharSequence)/replacement) char sequence. ``` fun CharSequence.replaceRange(     startIndex: Int,     endIndex: Int,     replacement: CharSequence ): CharSequence ``` Replaces the part of the string at the given range with the [replacement](replace-range#kotlin.text%24replaceRange(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.CharSequence)/replacement) char sequence. ``` fun String.replaceRange(     startIndex: Int,     endIndex: Int,     replacement: CharSequence ): String ``` Returns a char sequence with content of this char sequence where its part at the given [range](replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/range) is replaced with the [replacement](replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/replacement) char sequence. ``` fun CharSequence.replaceRange(     range: IntRange,     replacement: CharSequence ): CharSequence ``` Replace the part of string at the given [range](replace-range#kotlin.text%24replaceRange(kotlin.String,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/range) with the [replacement](replace-range#kotlin.text%24replaceRange(kotlin.String,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/replacement) string. ``` fun String.replaceRange(     range: IntRange,     replacement: CharSequence ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <reversed> Returns a char sequence with characters in reversed order. ``` fun CharSequence.reversed(): CharSequence ``` Returns a string with characters in reversed order. ``` fun String.reversed(): String ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](running-fold) Returns a list containing successive accumulation values generated by applying [operation](running-fold#kotlin.text%24runningFold(kotlin.CharSequence,%20kotlin.text.runningFold.R,%20kotlin.Function2((kotlin.text.runningFold.R,%20kotlin.Char,%20)))/operation) from left to right to each character and current accumulator value that starts with [initial](running-fold#kotlin.text%24runningFold(kotlin.CharSequence,%20kotlin.text.runningFold.R,%20kotlin.Function2((kotlin.text.runningFold.R,%20kotlin.Char,%20)))/initial) value. ``` fun <R> CharSequence.runningFold(     initial: R,     operation: (acc: R, Char) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFoldIndexed](running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](running-fold-indexed#kotlin.text%24runningFoldIndexed(kotlin.CharSequence,%20kotlin.text.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.runningFoldIndexed.R,%20kotlin.Char,%20)))/operation) from left to right to each character, its index in the original char sequence and current accumulator value that starts with [initial](running-fold-indexed#kotlin.text%24runningFoldIndexed(kotlin.CharSequence,%20kotlin.text.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.runningFoldIndexed.R,%20kotlin.Char,%20)))/initial) value. ``` fun <R> CharSequence.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduce](running-reduce) Returns a list containing successive accumulation values generated by applying [operation](running-reduce#kotlin.text%24runningReduce(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to each character and current accumulator value that starts with the first character of this char sequence. ``` fun CharSequence.runningReduce(     operation: (acc: Char, Char) -> Char ): List<Char> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningReduceIndexed](running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](running-reduce-indexed#kotlin.text%24runningReduceIndexed(kotlin.CharSequence,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from left to right to each character, its index in the original char sequence and current accumulator value that starts with the first character of this char sequence. ``` fun CharSequence.runningReduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): List<Char> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### <scan> Returns a list containing successive accumulation values generated by applying [operation](scan#kotlin.text%24scan(kotlin.CharSequence,%20kotlin.text.scan.R,%20kotlin.Function2((kotlin.text.scan.R,%20kotlin.Char,%20)))/operation) from left to right to each character and current accumulator value that starts with [initial](scan#kotlin.text%24scan(kotlin.CharSequence,%20kotlin.text.scan.R,%20kotlin.Function2((kotlin.text.scan.R,%20kotlin.Char,%20)))/initial) value. ``` fun <R> CharSequence.scan(     initial: R,     operation: (acc: R, Char) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [scanIndexed](scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](scan-indexed#kotlin.text%24scanIndexed(kotlin.CharSequence,%20kotlin.text.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.scanIndexed.R,%20kotlin.Char,%20)))/operation) from left to right to each character, its index in the original char sequence and current accumulator value that starts with [initial](scan-indexed#kotlin.text%24scanIndexed(kotlin.CharSequence,%20kotlin.text.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.scanIndexed.R,%20kotlin.Char,%20)))/initial) value. ``` fun <R> CharSequence.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): List<R> ``` **Platform and version requirements:** JS (1.4) #### <set> Sets the character at the specified [index](set#kotlin.text%24set(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.Char)/index) to the specified [value](set#kotlin.text%24set(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.Char)/value). ``` operator fun StringBuilder.set(index: Int, value: Char) ``` **Platform and version requirements:** JS (1.4) #### [setRange](set-range) Replaces characters in the specified range of this string builder with characters in the specified string [value](set-range#kotlin.text%24setRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.Int,%20kotlin.String)/value) and returns this instance. ``` fun StringBuilder.setRange(     startIndex: Int,     endIndex: Int,     value: String ): StringBuilder ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <single> Returns the single character, or throws an exception if the char sequence is empty or has more than one character. ``` fun CharSequence.single(): Char ``` Returns the single character matching the given [predicate](single#kotlin.text%24single(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching character. ``` fun CharSequence.single(predicate: (Char) -> Boolean): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [singleOrNull](single-or-null) Returns single character, or `null` if the char sequence is empty or has more than one character. ``` fun CharSequence.singleOrNull(): Char? ``` Returns the single character matching the given [predicate](single-or-null#kotlin.text%24singleOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if character was not found or more than one character was found. ``` fun CharSequence.singleOrNull(     predicate: (Char) -> Boolean ): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <slice> Returns a char sequence containing characters of the original char sequence at the specified range of [indices](slice#kotlin.text%24slice(kotlin.CharSequence,%20kotlin.ranges.IntRange)/indices). ``` fun CharSequence.slice(indices: IntRange): CharSequence ``` Returns a string containing characters of the original string at the specified range of [indices](slice#kotlin.text%24slice(kotlin.String,%20kotlin.ranges.IntRange)/indices). ``` fun String.slice(indices: IntRange): String ``` Returns a char sequence containing characters of the original char sequence at specified [indices](slice#kotlin.text%24slice(kotlin.CharSequence,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun CharSequence.slice(indices: Iterable<Int>): CharSequence ``` Returns a string containing characters of the original string at specified [indices](slice#kotlin.text%24slice(kotlin.String,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun String.slice(indices: Iterable<Int>): String ``` #### <split> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Splits this char sequence to a list of strings around occurrences of the specified [delimiters](split#kotlin.text%24split(kotlin.CharSequence,%20kotlin.Array((kotlin.String)),%20kotlin.Boolean,%20kotlin.Int)/delimiters). ``` fun CharSequence.split(     vararg delimiters: String,     ignoreCase: Boolean = false,     limit: Int = 0 ): List<String> ``` ``` fun CharSequence.split(     vararg delimiters: Char,     ignoreCase: Boolean = false,     limit: Int = 0 ): List<String> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) Splits this char sequence to a list of strings around matches of the given regular expression. ``` fun CharSequence.split(     regex: Regex,     limit: Int = 0 ): List<String> ``` **Platform and version requirements:** JVM (1.0) Splits this char sequence around matches of the given regular expression. ``` fun CharSequence.split(     regex: Pattern,     limit: Int = 0 ): List<String> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [splitToSequence](split-to-sequence) Splits this char sequence to a sequence of strings around occurrences of the specified [delimiters](split-to-sequence#kotlin.text%24splitToSequence(kotlin.CharSequence,%20kotlin.Array((kotlin.String)),%20kotlin.Boolean,%20kotlin.Int)/delimiters). ``` fun CharSequence.splitToSequence(     vararg delimiters: String,     ignoreCase: Boolean = false,     limit: Int = 0 ): Sequence<String> ``` ``` fun CharSequence.splitToSequence(     vararg delimiters: Char,     ignoreCase: Boolean = false,     limit: Int = 0 ): Sequence<String> ``` Splits this char sequence to a sequence of strings around matches of the given regular expression. ``` fun CharSequence.splitToSequence(     regex: Regex,     limit: Int = 0 ): Sequence<String> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [startsWith](starts-with) Returns `true` if this char sequence starts with the specified character. ``` fun CharSequence.startsWith(     char: Char,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this char sequence starts with the specified prefix. ``` fun CharSequence.startsWith(     prefix: CharSequence,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if a substring of this char sequence starting at the specified offset [startIndex](starts-with#kotlin.text%24startsWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Boolean)/startIndex) starts with the specified prefix. ``` fun CharSequence.startsWith(     prefix: CharSequence,     startIndex: Int,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this string starts with the specified prefix. ``` fun String.startsWith(     prefix: String,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if a substring of this string starting at the specified offset [startIndex](starts-with#kotlin.text%24startsWith(kotlin.String,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/startIndex) starts with the specified prefix. ``` fun String.startsWith(     prefix: String,     startIndex: Int,     ignoreCase: Boolean = false ): Boolean ``` #### [String](-string) Converts the data from a portion of the specified array of bytes to characters using the specified character set and returns the conversion result as a string. **Platform and version requirements:** JVM (1.0) ``` fun String(     bytes: ByteArray,     offset: Int,     length: Int,     charset: Charset ): String ``` Converts the data from the specified array of bytes to characters using the specified character set and returns the conversion result as a string. **Platform and version requirements:** JVM (1.0) ``` fun String(bytes: ByteArray, charset: Charset): String ``` Converts the data from a portion of the specified array of bytes to characters using the UTF-8 character set and returns the conversion result as a string. **Platform and version requirements:** JVM (1.0) ``` fun String(     bytes: ByteArray,     offset: Int,     length: Int ): String ``` Converts the data from the specified array of bytes to characters using the UTF-8 character set and returns the conversion result as a string. **Platform and version requirements:** JVM (1.0) ``` fun String(bytes: ByteArray): String ``` Converts the code points from a portion of the specified Unicode code point array to a string. **Platform and version requirements:** JVM (1.0) ``` fun String(     codePoints: IntArray,     offset: Int,     length: Int ): String ``` Converts the contents of the specified StringBuffer to a string. **Platform and version requirements:** JVM (1.0) ``` fun String(stringBuffer: StringBuffer): String ``` Converts the contents of the specified StringBuilder to a string. **Platform and version requirements:** JVM (1.0) ``` fun String(stringBuilder: StringBuilder): String ``` Converts the characters in the specified array to a string. **Platform and version requirements:** JS (1.2), Native (1.3) ``` fun String(chars: CharArray): String ``` **Platform and version requirements:** JVM (1.0) ``` fun String(chars: CharArray): String ``` Converts the characters from a portion of the specified array to a string. **Platform and version requirements:** JS (1.2), Native (1.3) ``` fun String(     chars: CharArray,     offset: Int,     length: Int ): String ``` **Platform and version requirements:** JVM (1.0) ``` fun String(     chars: CharArray,     offset: Int,     length: Int ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subSequence](sub-sequence) Returns a subsequence of this char sequence specified by the given [range](sub-sequence#kotlin.text%24subSequence(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) of indices. ``` fun CharSequence.subSequence(range: IntRange): CharSequence ``` Returns a subsequence of this char sequence. ``` fun String.subSequence(start: Int, end: Int): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <substring> Returns a substring specified by the given [range](substring#kotlin.text%24substring(kotlin.String,%20kotlin.ranges.IntRange)/range) of indices. ``` fun String.substring(range: IntRange): String ``` Returns a substring of chars from a range of this char sequence starting at the [startIndex](substring#kotlin.text%24substring(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/startIndex) and ending right before the [endIndex](substring#kotlin.text%24substring(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/endIndex). ``` fun CharSequence.substring(     startIndex: Int,     endIndex: Int = length ): String ``` Returns a substring of chars at indices from the specified [range](substring#kotlin.text%24substring(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) of this char sequence. ``` fun CharSequence.substring(range: IntRange): String ``` Returns a substring of this string that starts at the specified [startIndex](substring#kotlin.text%24substring(kotlin.String,%20kotlin.Int)/startIndex) and continues to the end of the string. ``` fun String.substring(startIndex: Int): String ``` Returns the substring of this string starting at the [startIndex](substring#kotlin.text%24substring(kotlin.String,%20kotlin.Int,%20kotlin.Int)/startIndex) and ending right before the [endIndex](substring#kotlin.text%24substring(kotlin.String,%20kotlin.Int,%20kotlin.Int)/endIndex). ``` fun String.substring(startIndex: Int, endIndex: Int): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [substringAfter](substring-after) Returns a substring after the first occurrence of [delimiter](substring-after#kotlin.text%24substringAfter(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](substring-after#kotlin.text%24substringAfter(kotlin.String,%20kotlin.Char,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. ``` fun String.substringAfter(     delimiter: Char,     missingDelimiterValue: String = this ): String ``` ``` fun String.substringAfter(     delimiter: String,     missingDelimiterValue: String = this ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [substringAfterLast](substring-after-last) Returns a substring after the last occurrence of [delimiter](substring-after-last#kotlin.text%24substringAfterLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](substring-after-last#kotlin.text%24substringAfterLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. ``` fun String.substringAfterLast(     delimiter: Char,     missingDelimiterValue: String = this ): String ``` ``` fun String.substringAfterLast(     delimiter: String,     missingDelimiterValue: String = this ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [substringBefore](substring-before) Returns a substring before the first occurrence of [delimiter](substring-before#kotlin.text%24substringBefore(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](substring-before#kotlin.text%24substringBefore(kotlin.String,%20kotlin.Char,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. ``` fun String.substringBefore(     delimiter: Char,     missingDelimiterValue: String = this ): String ``` ``` fun String.substringBefore(     delimiter: String,     missingDelimiterValue: String = this ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [substringBeforeLast](substring-before-last) Returns a substring before the last occurrence of [delimiter](substring-before-last#kotlin.text%24substringBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](substring-before-last#kotlin.text%24substringBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. ``` fun String.substringBeforeLast(     delimiter: Char,     missingDelimiterValue: String = this ): String ``` ``` fun String.substringBeforeLast(     delimiter: String,     missingDelimiterValue: String = this ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](sum-by) Returns the sum of all values produced by [selector](sum-by#kotlin.text%24sumBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Int)))/selector) function applied to each character in the char sequence. ``` fun CharSequence.sumBy(selector: (Char) -> Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumByDouble](sum-by-double) Returns the sum of all values produced by [selector](sum-by-double#kotlin.text%24sumByDouble(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence. ``` fun CharSequence.sumByDouble(     selector: (Char) -> Double ): Double ``` #### [sumOf](sum-of) Returns the sum of all values produced by [selector](sum-of#kotlin.text%24sumOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharSequence.sumOf(selector: (Char) -> Double): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharSequence.sumOf(selector: (Char) -> Int): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharSequence.sumOf(selector: (Char) -> Long): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun CharSequence.sumOf(selector: (Char) -> UInt): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun CharSequence.sumOf(selector: (Char) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun CharSequence.sumOf(     selector: (Char) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun CharSequence.sumOf(     selector: (Char) -> BigInteger ): BigInteger ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <take> Returns a subsequence of this char sequence containing the first [n](take#kotlin.text%24take(kotlin.CharSequence,%20kotlin.Int)/n) characters from this char sequence, or the entire char sequence if this char sequence is shorter. ``` fun CharSequence.take(n: Int): CharSequence ``` Returns a string containing the first [n](take#kotlin.text%24take(kotlin.String,%20kotlin.Int)/n) characters from this string, or the entire string if this string is shorter. ``` fun String.take(n: Int): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](take-last) Returns a subsequence of this char sequence containing the last [n](take-last#kotlin.text%24takeLast(kotlin.CharSequence,%20kotlin.Int)/n) characters from this char sequence, or the entire char sequence if this char sequence is shorter. ``` fun CharSequence.takeLast(n: Int): CharSequence ``` Returns a string containing the last [n](take-last#kotlin.text%24takeLast(kotlin.String,%20kotlin.Int)/n) characters from this string, or the entire string if this string is shorter. ``` fun String.takeLast(n: Int): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](take-last-while) Returns a subsequence of this char sequence containing last characters that satisfy the given [predicate](take-last-while#kotlin.text%24takeLastWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.takeLastWhile(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string containing last characters that satisfy the given [predicate](take-last-while#kotlin.text%24takeLastWhile(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun String.takeLastWhile(     predicate: (Char) -> Boolean ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](take-while) Returns a subsequence of this char sequence containing the first characters that satisfy the given [predicate](take-while#kotlin.text%24takeWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.takeWhile(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string containing the first characters that satisfy the given [predicate](take-while#kotlin.text%24takeWhile(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun String.takeWhile(predicate: (Char) -> Boolean): String ``` #### <titlecase> **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) Converts this character to title case using Unicode mapping rules of the invariant locale. ``` fun Char.titlecase(): String ``` **Platform and version requirements:** JVM (1.5) Converts this character to title case using Unicode mapping rules of the specified [locale](titlecase#kotlin.text%24titlecase(kotlin.Char,%20java.util.Locale)/locale). ``` fun Char.titlecase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5) #### [titlecaseChar](titlecase-char) Converts this character to title case using Unicode mapping rules of the invariant locale. ``` fun Char.titlecaseChar(): Char ``` **Platform and version requirements:** JVM (1.2) #### [toBigDecimal](to-big-decimal) Parses the string as a [java.math.BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) number and returns the result. ``` fun String.toBigDecimal(): BigDecimal ``` ``` fun String.toBigDecimal(mathContext: MathContext): BigDecimal ``` **Platform and version requirements:** JVM (1.2) #### [toBigDecimalOrNull](to-big-decimal-or-null) Parses the string as a [java.math.BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toBigDecimalOrNull(): BigDecimal? ``` ``` fun String.toBigDecimalOrNull(     mathContext: MathContext ): BigDecimal? ``` **Platform and version requirements:** JVM (1.2) #### [toBigInteger](to-big-integer) Parses the string as a [java.math.BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number and returns the result. ``` fun String.toBigInteger(): BigInteger ``` ``` fun String.toBigInteger(radix: Int): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### [toBigIntegerOrNull](to-big-integer-or-null) Parses the string as a [java.math.BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toBigIntegerOrNull(): BigInteger? ``` ``` fun String.toBigIntegerOrNull(radix: Int): BigInteger? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBoolean](to-boolean) Returns `true` if the content of this string is equal to the word "true", ignoring case, and `false` otherwise. ``` fun String.toBoolean(): Boolean ``` Returns `true` if this string is not `null` and its content is equal to the word "true", ignoring case, and `false` otherwise. ``` fun String?.toBoolean(): Boolean ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toBooleanStrict](to-boolean-strict) Returns `true` if the content of this string is equal to the word "true", `false` if it is equal to "false", and throws an exception otherwise. ``` fun String.toBooleanStrict(): Boolean ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toBooleanStrictOrNull](to-boolean-strict-or-null) Returns `true` if the content of this string is equal to the word "true", `false` if it is equal to "false", and `null` otherwise. ``` fun String.toBooleanStrictOrNull(): Boolean? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Parses the string as a signed [Byte](../kotlin/-byte/index#kotlin.Byte) number and returns the result. ``` fun String.toByte(): Byte ``` ``` fun String.toByte(radix: Int): Byte ``` **Platform and version requirements:** JVM (1.0) #### [toByteArray](to-byte-array) Encodes the contents of this string using the specified character set and returns the resulting byte array. ``` fun String.toByteArray(     charset: Charset = Charsets.UTF_8 ): ByteArray ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toByteOrNull](to-byte-or-null) Parses the string as a signed [Byte](../kotlin/-byte/index#kotlin.Byte) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toByteOrNull(): Byte? ``` ``` fun String.toByteOrNull(radix: Int): Byte? ``` #### [toCharArray](to-char-array) **Platform and version requirements:** JVM (1.0) Copies characters from this string into the [destination](to-char-array#kotlin.text%24toCharArray(kotlin.String,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) character array and returns that array. ``` fun String.toCharArray(     destination: CharArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = length ): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.4), Native (1.3) Returns a [CharArray](../kotlin/-char-array/index#kotlin.CharArray) containing characters of this string. ``` fun String.toCharArray(): CharArray ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.3) Returns a [CharArray](../kotlin/-char-array/index#kotlin.CharArray) containing characters of this string or its substring. ``` fun String.toCharArray(     startIndex: Int = 0,     endIndex: Int = this.length ): CharArray ``` **Platform and version requirements:** JS (1.4) Copies characters from this string builder into the [destination](to-char-array#kotlin.text%24toCharArray(kotlin.text.StringBuilder,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) character array. ``` fun StringBuilder.toCharArray(     destination: CharArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = this.length) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](to-collection) Appends all characters to the given [destination](to-collection#kotlin.text%24toCollection(kotlin.CharSequence,%20kotlin.text.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Char>> CharSequence.toCollection(     destination: C ): C ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDouble](to-double) Parses the string as a [Double](../kotlin/-double/index#kotlin.Double) number and returns the result. ``` fun String.toDouble(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleOrNull](to-double-or-null) Parses the string as a [Double](../kotlin/-double/index#kotlin.Double) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toDoubleOrNull(): Double? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloat](to-float) Parses the string as a [Float](../kotlin/-float/index#kotlin.Float) number and returns the result. ``` fun String.toFloat(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatOrNull](to-float-or-null) Parses the string as a [Float](../kotlin/-float/index#kotlin.Float) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toFloatOrNull(): Float? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toHashSet](to-hash-set) Returns a new [HashSet](../kotlin.collections/-hash-set/index#kotlin.collections.HashSet) of all characters. ``` fun CharSequence.toHashSet(): HashSet<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toInt](to-int) Parses the string as an [Int](../kotlin/-int/index#kotlin.Int) number and returns the result. ``` fun String.toInt(): Int ``` ``` fun String.toInt(radix: Int): Int ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toIntOrNull](to-int-or-null) Parses the string as an [Int](../kotlin/-int/index#kotlin.Int) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toIntOrNull(): Int? ``` ``` fun String.toIntOrNull(radix: Int): Int? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](to-list) Returns a [List](../kotlin.collections/-list/index#kotlin.collections.List) containing all characters. ``` fun CharSequence.toList(): List<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLong](to-long) Parses the string as a [Long](../kotlin/-long/index#kotlin.Long) number and returns the result. ``` fun String.toLong(): Long ``` ``` fun String.toLong(radix: Int): Long ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toLongOrNull](to-long-or-null) Parses the string as a [Long](../kotlin/-long/index#kotlin.Long) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toLongOrNull(): Long? ``` ``` fun String.toLongOrNull(radix: Int): Long? ``` #### [toLowerCase](to-lower-case) **Platform and version requirements:** JVM (1.0) Returns a copy of this string converted to lower case using the rules of the specified locale. ``` fun String.toLowerCase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.0), JS (1.1) Converts this character to lower case using Unicode mapping rules of the invariant locale. ``` fun Char.toLowerCase(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) Returns a copy of this string converted to lower case using the rules of the default locale. ``` fun String.toLowerCase(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](to-mutable-list) Returns a new [MutableList](../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all characters of this char sequence. ``` fun CharSequence.toMutableList(): MutableList<Char> ``` **Platform and version requirements:** JVM (1.0) #### [toPattern](to-pattern) Converts the string into a regular expression [Pattern](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html) optionally with the specified [flags](to-pattern#kotlin.text%24toPattern(kotlin.String,%20kotlin.Int)/flags) from [Pattern](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html) or'd together so that strings can be split or matched on. ``` fun String.toPattern(flags: Int = 0): Pattern ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toRegex](to-regex) Converts the string into a regular expression [Regex](-regex/index#kotlin.text.Regex) with the default options. ``` fun String.toRegex(): Regex ``` Converts the string into a regular expression [Regex](-regex/index#kotlin.text.Regex) with the specified single [option](to-regex#kotlin.text%24toRegex(kotlin.String,%20kotlin.text.RegexOption)/option). ``` fun String.toRegex(option: RegexOption): Regex ``` Converts the string into a regular expression [Regex](-regex/index#kotlin.text.Regex) with the specified set of [options](to-regex#kotlin.text%24toRegex(kotlin.String,%20kotlin.collections.Set((kotlin.text.RegexOption)))/options). ``` fun String.toRegex(options: Set<RegexOption>): Regex ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toSet](to-set) Returns a [Set](../kotlin.collections/-set/index#kotlin.collections.Set) of all characters. ``` fun CharSequence.toSet(): Set<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShort](to-short) Parses the string as a [Short](../kotlin/-short/index#kotlin.Short) number and returns the result. ``` fun String.toShort(): Short ``` ``` fun String.toShort(radix: Int): Short ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toShortOrNull](to-short-or-null) Parses the string as a [Short](../kotlin/-short/index#kotlin.Short) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toShortOrNull(): Short? ``` ``` fun String.toShortOrNull(radix: Int): Short? ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all characters. ``` fun CharSequence.toSortedSet(): SortedSet<Char> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [toString](to-string) Returns a string representation of this [Byte](../kotlin/-byte/index#kotlin.Byte) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.UByte,%20kotlin.Int)/radix). ``` fun UByte.toString(radix: Int): String ``` ``` fun Byte.toString(radix: Int): String ``` Returns a string representation of this [Short](../kotlin/-short/index#kotlin.Short) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.UShort,%20kotlin.Int)/radix). ``` fun UShort.toString(radix: Int): String ``` ``` fun Short.toString(radix: Int): String ``` Returns a string representation of this [Int](../kotlin/-int/index#kotlin.Int) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.UInt,%20kotlin.Int)/radix). ``` fun UInt.toString(radix: Int): String ``` ``` fun Int.toString(radix: Int): String ``` Returns a string representation of this [Long](../kotlin/-long/index#kotlin.Long) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.ULong,%20kotlin.Int)/radix). ``` fun ULong.toString(radix: Int): String ``` ``` fun Long.toString(radix: Int): String ``` **Platform and version requirements:** JVM (1.0) #### [toTitleCase](to-title-case) Converts this character to title case using Unicode mapping rules of the invariant locale. ``` fun Char.toTitleCase(): Char ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUByte](to-u-byte) Parses the string as a signed [UByte](../kotlin/-u-byte/index) number and returns the result. ``` fun String.toUByte(): UByte ``` ``` fun String.toUByte(radix: Int): UByte ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUByteOrNull](to-u-byte-or-null) Parses the string as an [UByte](../kotlin/-u-byte/index) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toUByteOrNull(): UByte? ``` ``` fun String.toUByteOrNull(radix: Int): UByte? ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUInt](to-u-int) Parses the string as an [UInt](../kotlin/-u-int/index) number and returns the result. ``` fun String.toUInt(): UInt ``` ``` fun String.toUInt(radix: Int): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUIntOrNull](to-u-int-or-null) Parses the string as an [UInt](../kotlin/-u-int/index) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toUIntOrNull(): UInt? ``` ``` fun String.toUIntOrNull(radix: Int): UInt? ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULong](to-u-long) Parses the string as a [ULong](../kotlin/-u-long/index) number and returns the result. ``` fun String.toULong(): ULong ``` ``` fun String.toULong(radix: Int): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULongOrNull](to-u-long-or-null) Parses the string as an [ULong](../kotlin/-u-long/index) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toULongOrNull(): ULong? ``` ``` fun String.toULongOrNull(radix: Int): ULong? ``` #### [toUpperCase](to-upper-case) **Platform and version requirements:** JVM (1.0) Returns a copy of this string converted to upper case using the rules of the specified locale. ``` fun String.toUpperCase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.0), JS (1.1) Converts this character to upper case using Unicode mapping rules of the invariant locale. ``` fun Char.toUpperCase(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) Returns a copy of this string converted to upper case using the rules of the default locale. ``` fun String.toUpperCase(): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUShort](to-u-short) Parses the string as a [UShort](../kotlin/-u-short/index) number and returns the result. ``` fun String.toUShort(): UShort ``` ``` fun String.toUShort(radix: Int): UShort ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUShortOrNull](to-u-short-or-null) Parses the string as an [UShort](../kotlin/-u-short/index) number and returns the result or `null` if the string is not a valid representation of a number. ``` fun String.toUShortOrNull(): UShort? ``` ``` fun String.toUShortOrNull(radix: Int): UShort? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <trim> Returns a sub sequence of this char sequence having leading and trailing characters matching the [predicate](trim#kotlin.text%24trim(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun CharSequence.trim(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string having leading and trailing characters matching the [predicate](trim#kotlin.text%24trim(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun String.trim(predicate: (Char) -> Boolean): String ``` Returns a sub sequence of this char sequence having leading and trailing characters from the [chars](trim#kotlin.text%24trim(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. ``` fun CharSequence.trim(vararg chars: Char): CharSequence ``` Returns a string having leading and trailing characters from the [chars](trim#kotlin.text%24trim(kotlin.String,%20kotlin.CharArray)/chars) array removed. ``` fun String.trim(vararg chars: Char): String ``` Returns a sub sequence of this char sequence having leading and trailing whitespace removed. ``` fun CharSequence.trim(): CharSequence ``` Returns a string having leading and trailing whitespace removed. ``` fun String.trim(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [trimEnd](trim-end) Returns a sub sequence of this char sequence having trailing characters matching the [predicate](trim-end#kotlin.text%24trimEnd(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun CharSequence.trimEnd(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string having trailing characters matching the [predicate](trim-end#kotlin.text%24trimEnd(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun String.trimEnd(predicate: (Char) -> Boolean): String ``` Returns a sub sequence of this char sequence having trailing characters from the [chars](trim-end#kotlin.text%24trimEnd(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. ``` fun CharSequence.trimEnd(vararg chars: Char): CharSequence ``` Returns a string having trailing characters from the [chars](trim-end#kotlin.text%24trimEnd(kotlin.String,%20kotlin.CharArray)/chars) array removed. ``` fun String.trimEnd(vararg chars: Char): String ``` Returns a sub sequence of this char sequence having trailing whitespace removed. ``` fun CharSequence.trimEnd(): CharSequence ``` Returns a string having trailing whitespace removed. ``` fun String.trimEnd(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [trimIndent](trim-indent) Detects a common minimal indent of all the input lines, removes it from every line and also removes the first and the last lines if they are blank (notice difference blank vs empty). ``` fun String.trimIndent(): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [trimMargin](trim-margin) Trims leading whitespace characters followed by [marginPrefix](trim-margin#kotlin.text%24trimMargin(kotlin.String,%20kotlin.String)/marginPrefix) from every line of a source string and removes the first and the last lines if they are blank (notice difference blank vs empty). ``` fun String.trimMargin(marginPrefix: String = "|"): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [trimStart](trim-start) Returns a sub sequence of this char sequence having leading characters matching the [predicate](trim-start#kotlin.text%24trimStart(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun CharSequence.trimStart(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a string having leading characters matching the [predicate](trim-start#kotlin.text%24trimStart(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun String.trimStart(predicate: (Char) -> Boolean): String ``` Returns a sub sequence of this char sequence having leading characters from the [chars](trim-start#kotlin.text%24trimStart(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. ``` fun CharSequence.trimStart(vararg chars: Char): CharSequence ``` Returns a string having leading characters from the [chars](trim-start#kotlin.text%24trimStart(kotlin.String,%20kotlin.CharArray)/chars) array removed. ``` fun String.trimStart(vararg chars: Char): String ``` Returns a sub sequence of this char sequence having leading whitespace removed. ``` fun CharSequence.trimStart(): CharSequence ``` Returns a string having leading whitespace removed. ``` fun String.trimStart(): String ``` #### <uppercase> **Platform and version requirements:** JVM (1.5) Converts this character to upper case using Unicode mapping rules of the specified [locale](uppercase#kotlin.text%24uppercase(kotlin.Char,%20java.util.Locale)/locale). ``` fun Char.uppercase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.5) Returns a copy of this string converted to upper case using the rules of the specified [locale](uppercase#kotlin.text%24uppercase(kotlin.String,%20java.util.Locale)/locale). ``` fun String.uppercase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5) Converts this character to upper case using Unicode mapping rules of the invariant locale. ``` fun Char.uppercase(): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) Returns a copy of this string converted to upper case using Unicode mapping rules of the invariant locale. ``` fun String.uppercase(): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5) #### [uppercaseChar](uppercase-char) Converts this character to upper case using Unicode mapping rules of the invariant locale. ``` fun Char.uppercaseChar(): Char ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <windowed> Returns a list of snapshots of the window of the given [size](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this char sequence with the given [step](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a string. ``` fun CharSequence.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<String> ``` Returns a list of results of applying the given [transform](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/transform) function to an each char sequence representing a view over the window of the given [size](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/size) sliding along this char sequence with the given [step](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/step). ``` fun <R> CharSequence.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (CharSequence) -> R ): List<R> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowedSequence](windowed-sequence) Returns a sequence of snapshots of the window of the given [size](windowed-sequence#kotlin.text%24windowedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this char sequence with the given [step](windowed-sequence#kotlin.text%24windowedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a string. ``` fun CharSequence.windowedSequence(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): Sequence<String> ``` Returns a sequence of results of applying the given [transform](windowed-sequence#kotlin.text%24windowedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowedSequence.R)))/transform) function to an each char sequence representing a view over the window of the given [size](windowed-sequence#kotlin.text%24windowedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowedSequence.R)))/size) sliding along this char sequence with the given [step](windowed-sequence#kotlin.text%24windowedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowedSequence.R)))/step). ``` fun <R> CharSequence.windowedSequence(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (CharSequence) -> R ): Sequence<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [withIndex](with-index) Returns a lazy [Iterable](../kotlin.collections/-iterable/index#kotlin.collections.Iterable) that wraps each character of the original char sequence into an [IndexedValue](../kotlin.collections/-indexed-value/index) containing the index of that character and the character itself. ``` fun CharSequence.withIndex(): Iterable<IndexedValue<Char>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <zip> Returns a list of pairs built from the characters of `this` and the [other](zip#kotlin.text%24zip(kotlin.CharSequence,%20kotlin.CharSequence)/other) char sequences with the same index The returned list has length of the shortest char sequence. ``` infix fun CharSequence.zip(     other: CharSequence ): List<Pair<Char, Char>> ``` Returns a list of values built from the characters of `this` and the [other](zip#kotlin.text%24zip(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20kotlin.text.zip.V)))/other) char sequences with the same index using the provided [transform](zip#kotlin.text%24zip(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20kotlin.text.zip.V)))/transform) function applied to each pair of characters. The returned list has length of the shortest char sequence. ``` fun <V> CharSequence.zip(     other: CharSequence,     transform: (a: Char, b: Char) -> V ): List<V> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [zipWithNext](zip-with-next) Returns a list of pairs of each two adjacent characters in this char sequence. ``` fun CharSequence.zipWithNext(): List<Pair<Char, Char>> ``` Returns a list containing the results of applying the given [transform](zip-with-next#kotlin.text%24zipWithNext(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20kotlin.text.zipWithNext.R)))/transform) function to an each pair of two adjacent characters in this char sequence. ``` fun <R> CharSequence.zipWithNext(     transform: (a: Char, b: Char) -> R ): List<R> ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CASE\_INSENSITIVE\_ORDER](-c-a-s-e_-i-n-s-e-n-s-i-t-i-v-e_-o-r-d-e-r) A Comparator that orders strings ignoring character case. ``` val String.Companion.CASE_INSENSITIVE_ORDER: Comparator<String> ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.0) #### <format> Uses the provided [format](format#kotlin.text%24format(kotlin.String.Companion,%20kotlin.String,%20kotlin.Array((kotlin.Any?)))/format) as a format string and returns a string obtained by substituting the specified arguments, using the default locale. ``` fun String.Companion.format(     format: String,     vararg args: Any? ): String ``` Uses the provided [format](format#kotlin.text%24format(kotlin.String.Companion,%20java.util.Locale,%20kotlin.String,%20kotlin.Array((kotlin.Any?)))/format) as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. ``` fun String.Companion.format(     locale: Locale,     format: String,     vararg args: Any? ): String ``` Uses the provided [format](format#kotlin.text%24format(kotlin.String.Companion,%20java.util.Locale?,%20kotlin.String,%20kotlin.Array((kotlin.Any?)))/format) as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. If [locale](format#kotlin.text%24format(kotlin.String.Companion,%20java.util.Locale?,%20kotlin.String,%20kotlin.Array((kotlin.Any?)))/locale) is `null` then no localization is applied. ``` fun String.Companion.format(     locale: Locale?,     format: String,     vararg args: Any? ): String ```
programming_docs
kotlin associateWith associateWith ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [associateWith](associate-with) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <V> CharSequence.associateWith(     valueSelector: (Char) -> V ): Map<Char, V> ``` Returns a [Map](../kotlin.collections/-map/index#kotlin.collections.Map) where keys are characters from the given char sequence and values are produced by the [valueSelector](associate-with#kotlin.text%24associateWith(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.associateWith.V)))/valueSelector) function applied to each character. If any two characters are equal, the last one gets added to the map. The returned map preserves the entry iteration order of the original char sequence. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "bonne journée" // associate each character with its code val result = string.associateWith { char -> char.code } // notice each letter occurs only once println(result) // {b=98, o=111, n=110, e=101, =32, j=106, u=117, r=114, é=233} //sampleEnd } ``` kotlin orEmpty orEmpty ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [orEmpty](or-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String?.orEmpty(): String ``` Returns the string if it is not `null`, or the empty string otherwise. kotlin onEach onEach ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [onEach](on-each) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <S : CharSequence> S.onEach(     action: (Char) -> Unit ): S ``` Performs the given [action](on-each#kotlin.text%24onEach(kotlin.text.onEach.S,%20kotlin.Function1((kotlin.Char,%20kotlin.Unit)))/action) on each character and returns the char sequence itself afterwards. kotlin codePointAt codePointAt =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [codePointAt](code-point-at) **Platform and version requirements:** JVM (1.0) ``` fun String.codePointAt(index: Int): Int ``` Returns the character (Unicode code point) at the specified index. kotlin scan scan ==== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <scan> **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <R> CharSequence.scan(     initial: R,     operation: (acc: R, Char) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](scan#kotlin.text%24scan(kotlin.CharSequence,%20kotlin.text.scan.R,%20kotlin.Function2((kotlin.text.scan.R,%20kotlin.Char,%20)))/operation) from left to right to each character and current accumulator value that starts with [initial](scan#kotlin.text%24scan(kotlin.CharSequence,%20kotlin.text.scan.R,%20kotlin.Function2((kotlin.text.scan.R,%20kotlin.Char,%20)))/initial) value. Note that `acc` value passed to [operation](scan#kotlin.text%24scan(kotlin.CharSequence,%20kotlin.text.scan.R,%20kotlin.Function2((kotlin.text.scan.R,%20kotlin.Char,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.scan("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.scanIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().scan("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and a character, and calculates the next accumulator value. kotlin matches matches ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <matches> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun CharSequence.matches(regex: Regex): Boolean ``` Returns `true` if this char sequence matches the given regular expression. **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.6") fun String.matches(     regex: String ): Boolean ``` **Deprecated:** Use Regex.matches() instead kotlin lastOrNull lastOrNull ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [lastOrNull](last-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.lastOrNull(): Char? ``` Returns the last character, or `null` if the char sequence is empty. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "Kotlin 1.4.0" println(string.last()) // 0 println(string.last { it.isLetter() }) // n println(string.lastOrNull { it > 'z' }) // null // string.last { it > 'z' } // will fail val emptyString = "" println(emptyString.lastOrNull()) // null // emptyString.last() // will fail //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.lastOrNull(     predicate: (Char) -> Boolean ): Char? ``` Returns the last character matching the given [predicate](last-or-null#kotlin.text%24lastOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if no such character was found. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "Kotlin 1.4.0" println(string.last()) // 0 println(string.last { it.isLetter() }) // n println(string.lastOrNull { it > 'z' }) // null // string.last { it > 'z' } // will fail val emptyString = "" println(emptyString.lastOrNull()) // null // emptyString.last() // will fail //sampleEnd } ``` kotlin mapIndexedTo mapIndexedTo ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [mapIndexedTo](map-indexed-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(     destination: C,     transform: (index: Int, Char) -> R ): C ``` Applies the given [transform](map-indexed-to#kotlin.text%24mapIndexedTo(kotlin.CharSequence,%20kotlin.text.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexedTo.R)))/transform) function to each character and its index in the original char sequence and appends the results to the given [destination](map-indexed-to#kotlin.text%24mapIndexedTo(kotlin.CharSequence,%20kotlin.text.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexedTo.R)))/destination). Parameters ---------- `transform` - function that takes the index of a character and the character itself and returns the result of the transform applied to the character. kotlin maxWithOrNull maxWithOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [maxWithOrNull](max-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharSequence.maxWithOrNull(     comparator: Comparator<in Char> ): Char? ``` Returns the first character having the largest value according to the provided [comparator](max-with-or-null#kotlin.text%24maxWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.Char)))/comparator) or `null` if there are no characters. kotlin forEachIndexed forEachIndexed ============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [forEachIndexed](for-each-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.forEachIndexed(     action: (index: Int, Char) -> Unit) ``` Performs the given [action](for-each-indexed#kotlin.text%24forEachIndexed(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Unit)))/action) on each character, providing sequential index with the character. Parameters ---------- `action` - function that takes the index of a character and the character itself and performs the action on the character. kotlin filterIndexed filterIndexed ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [filterIndexed](filter-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.filterIndexed(     predicate: (index: Int, Char) -> Boolean ): CharSequence ``` Returns a char sequence containing only those characters from the original char sequence that match the given [predicate](filter-indexed#kotlin.text%24filterIndexed(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(0, 1, 2, 3, 4, 8, 6) val numbersOnSameIndexAsValue = numbers.filterIndexed { index, i -> index == i } println(numbersOnSameIndexAsValue) // [0, 1, 2, 3, 4, 6] //sampleEnd } ``` Parameters ---------- `predicate` - function that takes the index of a character and the character itself and returns the result of predicate evaluation on the character. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun String.filterIndexed(     predicate: (index: Int, Char) -> Boolean ): String ``` Returns a string containing only those characters from the original string that match the given [predicate](filter-indexed#kotlin.text%24filterIndexed(kotlin.String,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(0, 1, 2, 3, 4, 8, 6) val numbersOnSameIndexAsValue = numbers.filterIndexed { index, i -> index == i } println(numbersOnSameIndexAsValue) // [0, 1, 2, 3, 4, 6] //sampleEnd } ``` Parameters ---------- `predicate` - function that takes the index of a character and the character itself and returns the result of predicate evaluation on the character. kotlin substringBefore substringBefore =============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [substringBefore](substring-before) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.substringBefore(     delimiter: Char,     missingDelimiterValue: String = this ): String ``` ``` fun String.substringBefore(     delimiter: String,     missingDelimiterValue: String = this ): String ``` Returns a substring before the first occurrence of [delimiter](substring-before#kotlin.text%24substringBefore(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](substring-before#kotlin.text%24substringBefore(kotlin.String,%20kotlin.Char,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. kotlin padStart padStart ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [padStart](pad-start) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.padStart(     length: Int,     padChar: Char = ' ' ): CharSequence ``` Returns a char sequence with content of this char sequence padded at the beginning to the specified [length](pad-start#kotlin.text%24padStart(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/length) with the specified character or space. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val padWithSpace = "125".padStart(5) println("'$padWithSpace'") // ' 125' val padWithChar = "a".padStart(5, '.') println("'$padWithChar'") // '....a' // string is returned as is, when its length is greater than the specified val noPadding = "abcde".padStart(3) println("'$noPadding'") // 'abcde' //sampleEnd } ``` Parameters ---------- `length` - the desired string length. `padChar` - the character to pad string with, if it has length less than the [length](pad-start#kotlin.text%24padStart(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/length) specified. Space is used by default. **Return** Returns a char sequence of length at least [length](pad-start#kotlin.text%24padStart(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/length) consisting of `this` char sequence prepended with [padChar](pad-start#kotlin.text%24padStart(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/padChar) as many times as are necessary to reach that length. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.padStart(length: Int, padChar: Char = ' '): String ``` Pads the string to the specified [length](pad-start#kotlin.text%24padStart(kotlin.String,%20kotlin.Int,%20kotlin.Char)/length) at the beginning with the specified character or space. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val padWithSpace = "125".padStart(5) println("'$padWithSpace'") // ' 125' val padWithChar = "a".padStart(5, '.') println("'$padWithChar'") // '....a' // string is returned as is, when its length is greater than the specified val noPadding = "abcde".padStart(3) println("'$noPadding'") // 'abcde' //sampleEnd } ``` Parameters ---------- `length` - the desired string length. `padChar` - the character to pad string with, if it has length less than the [length](pad-start#kotlin.text%24padStart(kotlin.String,%20kotlin.Int,%20kotlin.Char)/length) specified. Space is used by default. **Return** Returns a string of length at least [length](pad-start#kotlin.text%24padStart(kotlin.String,%20kotlin.Int,%20kotlin.Char)/length) consisting of `this` string prepended with [padChar](pad-start#kotlin.text%24padStart(kotlin.String,%20kotlin.Int,%20kotlin.Char)/padChar) as many times as are necessary to reach that length. kotlin toUpperCase toUpperCase =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toUpperCase](to-upper-case) **Platform and version requirements:** JVM (1.0), JS (1.0) ``` @DeprecatedSinceKotlin("1.5") fun Char.toUpperCase(): Char ``` **Deprecated:** Use uppercaseChar() instead. Converts this character to upper case using Unicode mapping rules of the invariant locale. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") fun String.toUpperCase(): String ``` **Deprecated:** Use uppercase() instead. Returns a copy of this string converted to upper case using the rules of the default locale. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.5") fun String.toUpperCase(     locale: Locale ): String ``` **Deprecated:** Use uppercase() instead. Returns a copy of this string converted to upper case using the rules of the specified locale. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.toLong(): Long ``` Parses the string as a [Long](../kotlin/-long/index#kotlin.Long) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.toLong(radix: Int): Long ``` Parses the string as a [Long](../kotlin/-long/index#kotlin.Long) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. `IllegalArgumentException` - when [radix](to-long#kotlin.text%24toLong(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin split split ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <split> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.split(     vararg delimiters: String,     ignoreCase: Boolean = false,     limit: Int = 0 ): List<String> ``` Splits this char sequence to a list of strings around occurrences of the specified [delimiters](split#kotlin.text%24split(kotlin.CharSequence,%20kotlin.Array((kotlin.String)),%20kotlin.Boolean,%20kotlin.Int)/delimiters). Parameters ---------- `delimiters` - One or more strings to be used as delimiters. `ignoreCase` - `true` to ignore character case when matching a delimiter. By default `false`. `limit` - The maximum number of substrings to return. Zero by default means no limit is set. To avoid ambiguous results when strings in [delimiters](split#kotlin.text%24split(kotlin.CharSequence,%20kotlin.Array((kotlin.String)),%20kotlin.Boolean,%20kotlin.Int)/delimiters) have characters in common, this method proceeds from the beginning to the end of this string, and matches at each position the first element in [delimiters](split#kotlin.text%24split(kotlin.CharSequence,%20kotlin.Array((kotlin.String)),%20kotlin.Boolean,%20kotlin.Int)/delimiters) that is equal to a delimiter in this instance at that position. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.split(     vararg delimiters: Char,     ignoreCase: Boolean = false,     limit: Int = 0 ): List<String> ``` Splits this char sequence to a list of strings around occurrences of the specified [delimiters](split#kotlin.text%24split(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Boolean,%20kotlin.Int)/delimiters). Parameters ---------- `delimiters` - One or more characters to be used as delimiters. `ignoreCase` - `true` to ignore character case when matching a delimiter. By default `false`. `limit` - The maximum number of substrings to return. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.split(     regex: Regex,     limit: Int = 0 ): List<String> ``` Splits this char sequence to a list of strings around matches of the given regular expression. Parameters ---------- `limit` - Non-negative value specifying the maximum number of substrings to return. Zero by default means no limit is set. **Platform and version requirements:** JVM (1.0) ``` fun CharSequence.split(     regex: Pattern,     limit: Int = 0 ): List<String> ``` Splits this char sequence around matches of the given regular expression. This function has two notable differences from the method [Pattern.split](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#split-java.lang.CharSequence-int-): * the function returns the result as a `List<String>` rather than an `Array<String>`; * when the [limit](split#kotlin.text%24split(kotlin.CharSequence,%20java.util.regex.Pattern,%20kotlin.Int)/limit) is not specified or specified as 0, this function doesn't drop trailing empty strings from the result. Parameters ---------- `limit` - Non-negative value specifying the maximum number of substrings to return. Zero by default means no limit is set. kotlin endsWith endsWith ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [endsWith](ends-with) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.endsWith(     suffix: String,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this string ends with the specified suffix. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.endsWith(     char: Char,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this char sequence ends with the specified character. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.endsWith(     suffix: CharSequence,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if this char sequence ends with the specified suffix.
programming_docs
kotlin commonPrefixWith commonPrefixWith ================ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [commonPrefixWith](common-prefix-with) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.commonPrefixWith(     other: CharSequence,     ignoreCase: Boolean = false ): String ``` Returns the longest string `prefix` such that this char sequence and [other](common-prefix-with#kotlin.text%24commonPrefixWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) char sequence both start with this prefix, taking care not to split surrogate pairs. If this and [other](common-prefix-with#kotlin.text%24commonPrefixWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) have no common prefix, returns the empty string. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart println("Hot_Coffee".commonPrefixWith("Hot_cocoa")) // Hot_ println("Hot_Coffee".commonPrefixWith("Hot_cocoa", true)) // Hot_Co println("Hot_Coffee".commonPrefixWith("Iced_Coffee")) // //sampleEnd } ``` Parameters ---------- `ignoreCase` - `true` to ignore character case when matching a character. By default `false`. kotlin toIntOrNull toIntOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toIntOrNull](to-int-or-null) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun String.toIntOrNull(): Int? ``` Parses the string as an [Int](../kotlin/-int/index#kotlin.Int) number and returns the result or `null` if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun String.toIntOrNull(radix: Int): Int? ``` Parses the string as an [Int](../kotlin/-int/index#kotlin.Int) number and returns the result or `null` if the string is not a valid representation of a number. Exceptions ---------- `IllegalArgumentException` - when [radix](to-int-or-null#kotlin.text%24toIntOrNull(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin trimMargin trimMargin ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [trimMargin](trim-margin) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.trimMargin(marginPrefix: String = "|"): String ``` Trims leading whitespace characters followed by [marginPrefix](trim-margin#kotlin.text%24trimMargin(kotlin.String,%20kotlin.String)/marginPrefix) from every line of a source string and removes the first and the last lines if they are blank (notice difference blank vs empty). Doesn't affect a line if it doesn't contain [marginPrefix](trim-margin#kotlin.text%24trimMargin(kotlin.String,%20kotlin.String)/marginPrefix) except the first and the last blank lines. Doesn't preserve the original line endings. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val withoutMargin1 = """ABC |123 |456""".trimMargin() println(withoutMargin1) // ABC\n123\n456 val withoutMargin2 = """ #XYZ #foo #bar """.trimMargin("#") println(withoutMargin2) // XYZ\nfoo\nbar //sampleEnd } ``` Parameters ---------- `marginPrefix` - non-blank string, which is used as a margin delimiter. Default is `|` (pipe character). **See Also** [trimIndent](trim-indent) [kotlin.text.isWhitespace](is-whitespace#kotlin.text%24isWhitespace(kotlin.Char)) kotlin toByteOrNull toByteOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toByteOrNull](to-byte-or-null) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun String.toByteOrNull(): Byte? ``` Parses the string as a signed [Byte](../kotlin/-byte/index#kotlin.Byte) number and returns the result or `null` if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun String.toByteOrNull(radix: Int): Byte? ``` Parses the string as a signed [Byte](../kotlin/-byte/index#kotlin.Byte) number and returns the result or `null` if the string is not a valid representation of a number. Exceptions ---------- `IllegalArgumentException` - when [radix](to-byte-or-null#kotlin.text%24toByteOrNull(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin replaceIndent replaceIndent ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [replaceIndent](replace-indent) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceIndent(newIndent: String = ""): String ``` Detects a common minimal indent like it does [trimIndent](trim-indent) and replaces it with the specified [newIndent](replace-indent#kotlin.text%24replaceIndent(kotlin.String,%20kotlin.String)/newIndent). kotlin mapIndexedNotNull mapIndexedNotNull ================= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [mapIndexedNotNull](map-indexed-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R : Any> CharSequence.mapIndexedNotNull(     transform: (index: Int, Char) -> R? ): List<R> ``` Returns a list containing only the non-null results of applying the given [transform](map-indexed-not-null#kotlin.text%24mapIndexedNotNull(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexedNotNull.R?)))/transform) function to each character and its index in the original char sequence. Parameters ---------- `transform` - function that takes the index of a character and the character itself and returns the result of the transform applied to the character. kotlin isHighSurrogate isHighSurrogate =============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isHighSurrogate](is-high-surrogate) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun Char.isHighSurrogate(): Boolean ``` Returns `true` if this character is a Unicode high-surrogate code unit (also known as leading-surrogate code unit). kotlin isLetter isLetter ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isLetter](is-letter) **Platform and version requirements:** JVM (1.0), JS (1.5) ``` fun Char.isLetter(): Boolean ``` Returns `true` if this character is a letter. A character is considered to be a letter if its category is [CharCategory.UPPERCASE\_LETTER](-char-category/-u-p-p-e-r-c-a-s-e_-l-e-t-t-e-r#kotlin.text.CharCategory.UPPERCASE_LETTER), [CharCategory.LOWERCASE\_LETTER](-char-category/-l-o-w-e-r-c-a-s-e_-l-e-t-t-e-r#kotlin.text.CharCategory.LOWERCASE_LETTER), [CharCategory.TITLECASE\_LETTER](-char-category/-t-i-t-l-e-c-a-s-e_-l-e-t-t-e-r#kotlin.text.CharCategory.TITLECASE_LETTER), [CharCategory.MODIFIER\_LETTER](-char-category/-m-o-d-i-f-i-e-r_-l-e-t-t-e-r#kotlin.text.CharCategory.MODIFIER_LETTER), or [CharCategory.OTHER\_LETTER](-char-category/-o-t-h-e-r_-l-e-t-t-e-r#kotlin.text.CharCategory.OTHER_LETTER). ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('a', 'β', '+', '1') val (letters, notLetters) = chars.partition { it.isLetter() } println(letters) // [a, β] println(notLetters) // [+, 1] //sampleEnd } ``` kotlin codePointBefore codePointBefore =============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [codePointBefore](code-point-before) **Platform and version requirements:** JVM (1.0) ``` fun String.codePointBefore(index: Int): Int ``` Returns the character (Unicode code point) before the specified index. kotlin insertRange insertRange =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [insertRange](insert-range) **Platform and version requirements:** JS (1.4) ``` fun StringBuilder.insertRange(     index: Int,     value: CharArray,     startIndex: Int,     endIndex: Int ): StringBuilder ``` Inserts characters in a subarray of the specified character array [value](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/value) into this string builder at the specified [index](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/index) and returns this instance. The inserted characters go in same order as in the [value](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/value) array, starting at [index](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/index). Parameters ---------- `index` - the position in this string builder to insert at. `value` - the array from which characters are inserted. `startIndex` - the beginning (inclusive) of the subarray to insert. `endIndex` - the end (exclusive) of the subarray to insert. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) when [startIndex](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/startIndex) or [endIndex](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/endIndex) is out of range of the [value](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/value) array indices or when `startIndex > endIndex`. `IndexOutOfBoundsException` - if [index](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/index) is less than zero or greater than the length of this string builder. **Platform and version requirements:** JS (1.4) ``` fun StringBuilder.insertRange(     index: Int,     value: CharSequence,     startIndex: Int,     endIndex: Int ): StringBuilder ``` Inserts characters in a subsequence of the specified character sequence [value](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) into this string builder at the specified [index](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/index) and returns this instance. The inserted characters go in the same order as in the [value](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) character sequence, starting at [index](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/index). Parameters ---------- `index` - the position in this string builder to insert at. `value` - the character sequence from which a subsequence is inserted. `startIndex` - the beginning (inclusive) of the subsequence to insert. `endIndex` - the end (exclusive) of the subsequence to insert. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) when [startIndex](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/startIndex) or [endIndex](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/endIndex) is out of range of the [value](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) character sequence indices or when `startIndex > endIndex`. `IndexOutOfBoundsException` - if [index](insert-range#kotlin.text%24insertRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/index) is less than zero or greater than the length of this string builder. kotlin regionMatches regionMatches ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [regionMatches](region-matches) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.regionMatches(     thisOffset: Int,     other: CharSequence,     otherOffset: Int,     length: Int,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if the specified range in this char sequence is equal to the specified range in another char sequence. Parameters ---------- `thisOffset` - the start offset in this char sequence of the substring to compare. `other` - the string against a substring of which the comparison is performed. `otherOffset` - the start offset in the other char sequence of the substring to compare. `length` - the length of the substring to compare. **Platform and version requirements:** JVM (1.0), Native (1.0) ``` fun String.regionMatches(     thisOffset: Int,     other: String,     otherOffset: Int,     length: Int,     ignoreCase: Boolean = false ): Boolean ``` Returns `true` if the specified range in this string is equal to the specified range in another string. Parameters ---------- `thisOffset` - the start offset in this string of the substring to compare. `other` - the string against a substring of which the comparison is performed. `otherOffset` - the start offset in the other string of the substring to compare. `length` - the length of the substring to compare. kotlin substringAfter substringAfter ============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [substringAfter](substring-after) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.substringAfter(     delimiter: Char,     missingDelimiterValue: String = this ): String ``` ``` fun String.substringAfter(     delimiter: String,     missingDelimiterValue: String = this ): String ``` Returns a substring after the first occurrence of [delimiter](substring-after#kotlin.text%24substringAfter(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](substring-after#kotlin.text%24substringAfter(kotlin.String,%20kotlin.Char,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. kotlin isNullOrEmpty isNullOrEmpty ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isNullOrEmpty](is-null-or-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence?.isNullOrEmpty(): Boolean ``` Returns `true` if this nullable char sequence is either `null` or empty. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun markdownLink(title: String?, url: String) = if (title.isNullOrEmpty()) url else "[$title]($url)" // plain link println(markdownLink(title = null, url = "https://kotlinlang.org")) // https://kotlinlang.org // link with custom title println(markdownLink(title = "Kotlin Language", url = "https://kotlinlang.org")) // [Kotlin Language](https://kotlinlang.org) //sampleEnd } ``` kotlin charset charset ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <charset> **Platform and version requirements:** JVM (1.0) ``` fun charset(charsetName: String): Charset ``` Returns a named charset with the given [charsetName](charset#kotlin.text%24charset(kotlin.String)/charsetName) name. Exceptions ---------- `UnsupportedCharsetException` - If the specified named charset is not available. kotlin lines lines ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <lines> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.lines(): List<String> ``` Splits this char sequence to a list of lines delimited by any of the following character sequences: CRLF, LF or CR. The lines returned do not include terminating line separators. kotlin isSurrogate isSurrogate =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isSurrogate](is-surrogate) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Char.isSurrogate(): Boolean ``` Returns `true` if this character is a Unicode surrogate code unit. kotlin runningFold runningFold =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [runningFold](running-fold) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <R> CharSequence.runningFold(     initial: R,     operation: (acc: R, Char) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](running-fold#kotlin.text%24runningFold(kotlin.CharSequence,%20kotlin.text.runningFold.R,%20kotlin.Function2((kotlin.text.runningFold.R,%20kotlin.Char,%20)))/operation) from left to right to each character and current accumulator value that starts with [initial](running-fold#kotlin.text%24runningFold(kotlin.CharSequence,%20kotlin.text.runningFold.R,%20kotlin.Function2((kotlin.text.runningFold.R,%20kotlin.Char,%20)))/initial) value. Note that `acc` value passed to [operation](running-fold#kotlin.text%24runningFold(kotlin.CharSequence,%20kotlin.text.runningFold.R,%20kotlin.Function2((kotlin.text.runningFold.R,%20kotlin.Char,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.runningFold("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.runningFoldIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().runningFold("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and a character, and calculates the next accumulator value. kotlin dropLast dropLast ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [dropLast](drop-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.dropLast(n: Int): CharSequence ``` Returns a subsequence of this char sequence with the last [n](drop-last#kotlin.text%24dropLast(kotlin.CharSequence,%20kotlin.Int)/n) characters removed. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.drop(6)) // st Grade>>> println(string.dropLast(6)) // <<<First Gr println(string.dropWhile { !it.isLetter() }) // First Grade>>> println(string.dropLastWhile { !it.isLetter() }) // <<<First Grade //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](drop-last#kotlin.text%24dropLast(kotlin.CharSequence,%20kotlin.Int)/n) is negative. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.dropLast(n: Int): String ``` Returns a string with the last [n](drop-last#kotlin.text%24dropLast(kotlin.String,%20kotlin.Int)/n) characters removed. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.drop(6)) // st Grade>>> println(string.dropLast(6)) // <<<First Gr println(string.dropWhile { !it.isLetter() }) // First Grade>>> println(string.dropLastWhile { !it.isLetter() }) // <<<First Grade //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](drop-last#kotlin.text%24dropLast(kotlin.String,%20kotlin.Int)/n) is negative.
programming_docs
kotlin mapIndexed mapIndexed ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [mapIndexed](map-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R> CharSequence.mapIndexed(     transform: (index: Int, Char) -> R ): List<R> ``` Returns a list containing the results of applying the given [transform](map-indexed#kotlin.text%24mapIndexed(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.text.mapIndexed.R)))/transform) function to each character and its index in the original char sequence. Parameters ---------- `transform` - function that takes the index of a character and the character itself and returns the result of the transform applied to the character. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.2), Native (1.3) ``` fun String.compareTo(     other: String,     ignoreCase: Boolean = false ): Int ``` Compares two strings lexicographically, optionally ignoring case differences. If [ignoreCase](compare-to#kotlin.text%24compareTo(kotlin.String,%20kotlin.String,%20kotlin.Boolean)/ignoreCase) is true, the result of `Char.uppercaseChar().lowercaseChar()` on each character is compared. kotlin repeat repeat ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <repeat> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun CharSequence.repeat(n: Int): String ``` Returns a string containing this char sequence repeated [n](repeat#kotlin.text%24repeat(kotlin.CharSequence,%20kotlin.Int)/n) times. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart println("Word".repeat(4)) // WordWordWordWord println("Word".repeat(0)) // //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - when n < 0. kotlin removeSuffix removeSuffix ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [removeSuffix](remove-suffix) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.removeSuffix(     suffix: CharSequence ): CharSequence ``` If this char sequence ends with the given [suffix](remove-suffix#kotlin.text%24removeSuffix(kotlin.CharSequence,%20kotlin.CharSequence)/suffix), returns a new char sequence with the suffix removed. Otherwise, returns a new char sequence with the same characters. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.removeSuffix(suffix: CharSequence): String ``` If this string ends with the given [suffix](remove-suffix#kotlin.text%24removeSuffix(kotlin.String,%20kotlin.CharSequence)/suffix), returns a copy of this string with the suffix removed. Otherwise, returns this string. kotlin isBlank isBlank ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isBlank](is-blank) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun CharSequence.isBlank(): Boolean ``` Returns `true` if this string is empty or consists solely of whitespace characters. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun validateName(name: String): String { if (name.isBlank()) throw IllegalArgumentException("Name cannot be blank") return name } println(validateName("Adam")) // Adam // validateName("") // will fail // validateName(" \t\n") // will fail //sampleEnd } ``` kotlin decapitalize decapitalize ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <decapitalize> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") fun String.decapitalize(): String ``` **Deprecated:** Use replaceFirstChar instead. Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart println("abcd".decapitalize()) // abcd println("Abcd".decapitalize()) // abcd //sampleEnd } ``` **Platform and version requirements:** JVM (1.4) ``` @DeprecatedSinceKotlin("1.5") fun String.decapitalize(     locale: Locale ): String ``` **Deprecated:** Use replaceFirstChar instead. Returns a copy of this string having its first letter lowercased using the rules of the specified [locale](decapitalize#kotlin.text%24decapitalize(kotlin.String,%20java.util.Locale)/locale), or the original string, if it's empty or already starts with a lower case letter. kotlin removeRange removeRange =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [removeRange](remove-range) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.removeRange(     startIndex: Int,     endIndex: Int ): CharSequence ``` Returns a char sequence with content of this char sequence where its part at the given range is removed. Parameters ---------- `startIndex` - the index of the first character to be removed. `endIndex` - the index of the first character after the removed part to keep in the string. [endIndex](remove-range#kotlin.text%24removeRange(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/endIndex) is not included in the removed part. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.removeRange(     startIndex: Int,     endIndex: Int ): String ``` Removes the part of a string at a given range. Parameters ---------- `startIndex` - the index of the first character to be removed. `endIndex` - the index of the first character after the removed part to keep in the string. [endIndex](remove-range#kotlin.text%24removeRange(kotlin.String,%20kotlin.Int,%20kotlin.Int)/endIndex) is not included in the removed part. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.removeRange(range: IntRange): CharSequence ``` Returns a char sequence with content of this char sequence where its part at the given [range](remove-range#kotlin.text%24removeRange(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) is removed. The end index of the [range](remove-range#kotlin.text%24removeRange(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) is included in the removed part. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.removeRange(range: IntRange): String ``` Removes the part of a string at the given [range](remove-range#kotlin.text%24removeRange(kotlin.String,%20kotlin.ranges.IntRange)/range). The end index of the [range](remove-range#kotlin.text%24removeRange(kotlin.String,%20kotlin.ranges.IntRange)/range) is included in the removed part. kotlin isDefined isDefined ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isDefined](is-defined) **Platform and version requirements:** JVM (1.0), JS (1.5) ``` fun Char.isDefined(): Boolean ``` Returns `true` if this character (Unicode code point) is defined in Unicode. A character is considered to be defined in Unicode if its category is not [CharCategory.UNASSIGNED](-char-category/-u-n-a-s-s-i-g-n-e-d#kotlin.text.CharCategory.UNASSIGNED). kotlin reduceRightIndexedOrNull reduceRightIndexedOrNull ======================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [reduceRightIndexedOrNull](reduce-right-indexed-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun CharSequence.reduceRightIndexedOrNull(     operation: (index: Int, Char, acc: Char) -> Char ): Char? ``` Accumulates value starting with the last character and applying [operation](reduce-right-indexed-or-null#kotlin.text%24reduceRightIndexedOrNull(kotlin.CharSequence,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from right to left to each character with its index in the original char sequence and current accumulator value. Returns `null` if the char sequence is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRightOrNull { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexedOrNull { index, string, acc -> acc + string + index }) // dc2b1a0 println(emptyList<String>().reduceRightOrNull { _, _ -> "" }) // null //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of a character, the character itself and current accumulator value, and calculates the next accumulator value. kotlin category category ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <category> **Platform and version requirements:** JVM (1.0), JS (1.5) ``` val Char.category: CharCategory ``` Returns the Unicode general category of this character. kotlin asIterable asIterable ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [asIterable](as-iterable) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.asIterable(): Iterable<Char> ``` Creates an [Iterable](../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original char sequence returning its characters when being iterated. kotlin directionality directionality ============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <directionality> **Platform and version requirements:** JVM (1.0) ``` val Char.directionality: CharDirectionality ``` Returns the Unicode directionality property for the given character. kotlin append append ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <append> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Appendable> T.append(vararg value: CharSequence?): T ``` Appends all arguments to the given [Appendable](-appendable/index#kotlin.text.Appendable). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun StringBuilder.append(obj: Any?): StringBuilder ``` **Deprecated:** Use append(value: Any?) instead ``` fun StringBuilder.append(     str: CharArray,     offset: Int,     len: Int ): StringBuilder ``` **Deprecated:** Use appendRange instead. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun StringBuilder.append(     vararg value: String? ): StringBuilder ``` ``` fun StringBuilder.append(vararg value: Any?): StringBuilder ``` Appends all arguments to the given StringBuilder. kotlin lastIndexOf lastIndexOf =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [lastIndexOf](last-index-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.lastIndexOf(     char: Char,     startIndex: Int = lastIndex,     ignoreCase: Boolean = false ): Int ``` Returns the index within this char sequence of the last occurrence of the specified character, starting from the specified [startIndex](last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.Char,%20kotlin.Int,%20kotlin.Boolean)/startIndex). Parameters ---------- `startIndex` - The index of character to start searching at. The search proceeds backward toward the beginning of the string. `ignoreCase` - `true` to ignore character case when matching a character. By default `false`. **Return** An index of the last occurrence of [char](last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.Char,%20kotlin.Int,%20kotlin.Boolean)/char) or -1 if none is found. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.lastIndexOf(     string: String,     startIndex: Int = lastIndex,     ignoreCase: Boolean = false ): Int ``` Returns the index within this char sequence of the last occurrence of the specified [string](last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/string), starting from the specified [startIndex](last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/startIndex). Parameters ---------- `startIndex` - The index of character to start searching at. The search proceeds backward toward the beginning of the string. `ignoreCase` - `true` to ignore character case when matching a string. By default `false`. **Return** An index of the last occurrence of [string](last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/string) or -1 if none is found. kotlin replaceIndentByMargin replaceIndentByMargin ===================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [replaceIndentByMargin](replace-indent-by-margin) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceIndentByMargin(     newIndent: String = "",     marginPrefix: String = "|" ): String ``` Detects indent by [marginPrefix](replace-indent-by-margin#kotlin.text%24replaceIndentByMargin(kotlin.String,%20kotlin.String,%20kotlin.String)/marginPrefix) as it does [trimMargin](trim-margin) and replace it with [newIndent](replace-indent-by-margin#kotlin.text%24replaceIndentByMargin(kotlin.String,%20kotlin.String,%20kotlin.String)/newIndent). Parameters ---------- `marginPrefix` - non-blank string, which is used as a margin delimiter. Default is `|` (pipe character). kotlin concatToString concatToString ============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [concatToString](concat-to-string) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun CharArray.concatToString(): String ``` Concatenates characters in this [CharArray](../kotlin/-char-array/index#kotlin.CharArray) into a String. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun CharArray.concatToString(     startIndex: Int = 0,     endIndex: Int = this.size ): String ``` Concatenates characters in this [CharArray](../kotlin/-char-array/index#kotlin.CharArray) or its subrange into a String. Parameters ---------- `startIndex` - the beginning (inclusive) of the subrange of characters, 0 by default. `endIndex` - the end (exclusive) of the subrange of characters, size of this array by default. Exceptions ---------- `IndexOutOfBoundsException` - if [startIndex](concat-to-string#kotlin.text%24concatToString(kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/startIndex) is less than zero or [endIndex](concat-to-string#kotlin.text%24concatToString(kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/endIndex) is greater than the size of this array. `IllegalArgumentException` - if [startIndex](concat-to-string#kotlin.text%24concatToString(kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/startIndex) is greater than [endIndex](concat-to-string#kotlin.text%24concatToString(kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/endIndex). kotlin setRange setRange ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [setRange](set-range) **Platform and version requirements:** JS (1.4) ``` fun StringBuilder.setRange(     startIndex: Int,     endIndex: Int,     value: String ): StringBuilder ``` Replaces characters in the specified range of this string builder with characters in the specified string [value](set-range#kotlin.text%24setRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.Int,%20kotlin.String)/value) and returns this instance. Parameters ---------- `startIndex` - the beginning (inclusive) of the range to replace. `endIndex` - the end (exclusive) of the range to replace. `value` - the string to replace with. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) if [startIndex](set-range#kotlin.text%24setRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.Int,%20kotlin.String)/startIndex) is less than zero, greater than the length of this string builder, or `startIndex > endIndex`. kotlin replaceBeforeLast replaceBeforeLast ================= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [replaceBeforeLast](replace-before-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceBeforeLast(     delimiter: Char,     replacement: String,     missingDelimiterValue: String = this ): String ``` ``` fun String.replaceBeforeLast(     delimiter: String,     replacement: String,     missingDelimiterValue: String = this ): String ``` Replace part of string before the last occurrence of given delimiter with the [replacement](replace-before-last#kotlin.text%24replaceBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/replacement) string. If the string does not contain the delimiter, returns [missingDelimiterValue](replace-before-last#kotlin.text%24replaceBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. kotlin foldRightIndexed foldRightIndexed ================ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [foldRightIndexed](fold-right-indexed) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R> CharSequence.foldRightIndexed(     initial: R,     operation: (index: Int, Char, acc: R) -> R ): R ``` Accumulates value starting with [initial](fold-right-indexed#kotlin.text%24foldRightIndexed(kotlin.CharSequence,%20kotlin.text.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20kotlin.text.foldRightIndexed.R,%20)))/initial) value and applying [operation](fold-right-indexed#kotlin.text%24foldRightIndexed(kotlin.CharSequence,%20kotlin.text.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20kotlin.text.foldRightIndexed.R,%20)))/operation) from right to left to each character with its index in the original char sequence and current accumulator value. Returns the specified [initial](fold-right-indexed#kotlin.text%24foldRightIndexed(kotlin.CharSequence,%20kotlin.text.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20kotlin.text.foldRightIndexed.R,%20)))/initial) value if the char sequence is empty. Parameters ---------- `operation` - function that takes the index of a character, the character itself and current accumulator value, and calculates the next accumulator value. kotlin indices indices ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <indices> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val CharSequence.indices: IntRange ``` Returns the range of valid character indices for this char sequence. kotlin appendRange appendRange =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [appendRange](append-range) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Appendable> T.appendRange(     value: CharSequence,     startIndex: Int,     endIndex: Int ): T ``` Appends a subsequence of the specified character sequence [value](append-range#kotlin.text%24appendRange(kotlin.text.appendRange.T,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) to this Appendable and returns this instance. Parameters ---------- `value` - the character sequence from which a subsequence is appended. `startIndex` - the beginning (inclusive) of the subsequence to append. `endIndex` - the end (exclusive) of the subsequence to append. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) when [startIndex](append-range#kotlin.text%24appendRange(kotlin.text.appendRange.T,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/startIndex) or [endIndex](append-range#kotlin.text%24appendRange(kotlin.text.appendRange.T,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/endIndex) is out of range of the [value](append-range#kotlin.text%24appendRange(kotlin.text.appendRange.T,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) character sequence indices or when `startIndex > endIndex`. **Platform and version requirements:** JS (1.4) ``` fun StringBuilder.appendRange(     value: CharArray,     startIndex: Int,     endIndex: Int ): StringBuilder ``` Appends characters in a subarray of the specified character array [value](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/value) to this string builder and returns this instance. Characters are appended in order, starting at specified [startIndex](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/startIndex). Parameters ---------- `value` - the array from which characters are appended. `startIndex` - the beginning (inclusive) of the subarray to append. `endIndex` - the end (exclusive) of the subarray to append. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) when [startIndex](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/startIndex) or [endIndex](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/endIndex) is out of range of the [value](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/value) array indices or when `startIndex > endIndex`. **Platform and version requirements:** JS (1.4) ``` fun StringBuilder.appendRange(     value: CharSequence,     startIndex: Int,     endIndex: Int ): StringBuilder ``` Appends a subsequence of the specified character sequence [value](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) to this string builder and returns this instance. Parameters ---------- `value` - the character sequence from which a subsequence is appended. `startIndex` - the beginning (inclusive) of the subsequence to append. `endIndex` - the end (exclusive) of the subsequence to append. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) when [startIndex](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/startIndex) or [endIndex](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/endIndex) is out of range of the [value](append-range#kotlin.text%24appendRange(kotlin.text.StringBuilder,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/value) character sequence indices or when `startIndex > endIndex`.
programming_docs
kotlin substringAfterLast substringAfterLast ================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [substringAfterLast](substring-after-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.substringAfterLast(     delimiter: Char,     missingDelimiterValue: String = this ): String ``` ``` fun String.substringAfterLast(     delimiter: String,     missingDelimiterValue: String = this ): String ``` Returns a substring after the last occurrence of [delimiter](substring-after-last#kotlin.text%24substringAfterLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](substring-after-last#kotlin.text%24substringAfterLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. kotlin count count ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <count> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.count(): Int ``` Returns the length of this char sequence. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.count(     predicate: (Char) -> Boolean ): Int ``` Returns the number of characters matching the given [predicate](count#kotlin.text%24count(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). kotlin flatMapIndexed flatMapIndexed ============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [flatMapIndexed](flat-map-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("flatMapIndexedIterable") inline fun <R> CharSequence.flatMapIndexed(     transform: (index: Int, Char) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map-indexed#kotlin.text%24flatMapIndexed(kotlin.CharSequence,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMapIndexed.R)))))/transform) function being invoked on each character and its index in the original char sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val data: List<String> = listOf("Abcd", "efgh", "Klmn") val selected: List<Boolean> = data.map { it.any { c -> c.isUpperCase() } } val result = data.flatMapIndexed { index, s -> if (selected[index]) s.toList() else emptyList() } println(result) // [A, b, c, d, K, l, m, n] //sampleEnd } ``` kotlin windowed windowed ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <windowed> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun CharSequence.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false ): List<String> ``` Returns a list of snapshots of the window of the given [size](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this char sequence with the given [step](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step), where each snapshot is a string. Several last strings may have fewer characters than the given [size](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size). Both [size](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) and [step](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/step) must be positive and can be greater than the number of elements in this char sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val sequence = generateSequence(1) { it + 1 } val windows = sequence.windowed(size = 5, step = 1) println(windows.take(4).toList()) // [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]] val moreSparseWindows = sequence.windowed(size = 5, step = 3) println(moreSparseWindows.take(4).toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14]] val fullWindows = sequence.take(10).windowed(size = 5, step = 3) println(fullWindows.toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8]] val partialWindows = sequence.take(10).windowed(size = 5, step = 3, partialWindows = true) println(partialWindows.toList()) // [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10], [10]] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each window `step` - the number of elements to move the window forward by on an each step, by default 1 `partialWindows` - controls whether or not to keep partial windows in the end if any, by default `false` which means partial windows won't be preserved **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun <R> CharSequence.windowed(     size: Int,     step: Int = 1,     partialWindows: Boolean = false,     transform: (CharSequence) -> R ): List<R> ``` Returns a list of results of applying the given [transform](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/transform) function to an each char sequence representing a view over the window of the given [size](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/size) sliding along this char sequence with the given [step](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/step). Note that the char sequence passed to the [transform](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/transform) function is ephemeral and is valid only inside that function. You should not store it or allow it to escape in some way, unless you made a snapshot of it. Several last char sequences may have fewer characters than the given [size](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/size). Both [size](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/size) and [step](windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.windowed.R)))/step) must be positive and can be greater than the number of elements in this char sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val dataPoints = sequenceOf(10, 15, 18, 25, 19, 21, 14, 8, 5) val averaged = dataPoints.windowed(size = 4, step = 1, partialWindows = true) { window -> window.average() } println(averaged.toList()) // [17.0, 19.25, 20.75, 19.75, 15.5, 12.0, 9.0, 6.5, 5.0] val averagedNoPartialWindows = dataPoints.windowed(size = 4, step = 1).map { it.average() } println(averagedNoPartialWindows.toList()) // [17.0, 19.25, 20.75, 19.75, 15.5, 12.0] //sampleEnd } ``` Parameters ---------- `size` - the number of elements to take in each window `step` - the number of elements to move the window forward by on an each step, by default 1 `partialWindows` - controls whether or not to keep partial windows in the end if any, by default `false` which means partial windows won't be preserved kotlin toTitleCase toTitleCase =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toTitleCase](to-title-case) **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.5") fun Char.toTitleCase(): Char ``` **Deprecated:** Use titlecaseChar() instead. Converts this character to title case using Unicode mapping rules of the invariant locale. **See Also** [Character.toTitleCase](https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html#toTitleCase-char-) kotlin asSequence asSequence ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [asSequence](as-sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.asSequence(): Sequence<Char> ``` Creates a [Sequence](../kotlin.sequences/-sequence/index) instance that wraps the original char sequence returning its characters when being iterated. kotlin scanIndexed scanIndexed =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [scanIndexed](scan-indexed) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <R> CharSequence.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> R ): List<R> ``` Returns a list containing successive accumulation values generated by applying [operation](scan-indexed#kotlin.text%24scanIndexed(kotlin.CharSequence,%20kotlin.text.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.scanIndexed.R,%20kotlin.Char,%20)))/operation) from left to right to each character, its index in the original char sequence and current accumulator value that starts with [initial](scan-indexed#kotlin.text%24scanIndexed(kotlin.CharSequence,%20kotlin.text.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.scanIndexed.R,%20kotlin.Char,%20)))/initial) value. Note that `acc` value passed to [operation](scan-indexed#kotlin.text%24scanIndexed(kotlin.CharSequence,%20kotlin.text.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.text.scanIndexed.R,%20kotlin.Char,%20)))/operation) function should not be mutated; otherwise it would affect the previous value in resulting list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.scan("s") { acc, string -> acc + string }) // [s, sa, sab, sabc, sabcd] println(strings.scanIndexed("s") { index, acc, string -> acc + string + index }) // [s, sa0, sa0b1, sa0b1c2, sa0b1c2d3] println(emptyList<String>().scan("s") { _, _ -> "X" }) // [s] //sampleEnd } ``` Parameters ---------- `operation` - function that takes the index of a character, current accumulator value and the character itself, and calculates the next accumulator value. kotlin replace replace ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <replace> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replace(     oldChar: Char,     newChar: Char,     ignoreCase: Boolean = false ): String ``` Returns a new string with all occurrences of [oldChar](replace#kotlin.text%24replace(kotlin.String,%20kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/oldChar) replaced with [newChar](replace#kotlin.text%24replace(kotlin.String,%20kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/newChar). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val inputString0 = "Mississippi" val inputString1 = "Insufficient data for meaningful answer." println(inputString0.replace('s', 'z')) // Mizzizzippi println(inputString1.replace("data", "information")) // Insufficient information for meaningful answer. //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replace(     oldValue: String,     newValue: String,     ignoreCase: Boolean = false ): String ``` Returns a new string obtained by replacing all occurrences of the [oldValue](replace#kotlin.text%24replace(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.Boolean)/oldValue) substring in this string with the specified [newValue](replace#kotlin.text%24replace(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.Boolean)/newValue) string. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val inputString0 = "Mississippi" val inputString1 = "Insufficient data for meaningful answer." println(inputString0.replace('s', 'z')) // Mizzizzippi println(inputString1.replace("data", "information")) // Insufficient information for meaningful answer. //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.replace(     regex: Regex,     replacement: String ): String ``` Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the given [replacement](replace#kotlin.text%24replace(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/replacement). The [replacement](replace#kotlin.text%24replace(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/replacement) can consist of any combination of literal text and $-substitutions. To treat the replacement string literally escape it with the [kotlin.text.Regex.Companion.escapeReplacement](-regex/escape-replacement#kotlin.text.Regex.Companion%24escapeReplacement(kotlin.String)) method. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.replace(     regex: Regex,     noinline transform: (MatchResult) -> CharSequence ): String ``` Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the result of the given function [transform](replace#kotlin.text%24replace(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.Function1((kotlin.text.MatchResult,%20kotlin.CharSequence)))/transform) that takes [MatchResult](-match-result/index) and returns a string to be used as a replacement for that match. kotlin lineSequence lineSequence ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [lineSequence](line-sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.lineSequence(): Sequence<String> ``` Splits this char sequence to a sequence of lines delimited by any of the following character sequences: CRLF, LF or CR. The lines returned do not include terminating line separators. kotlin toLowerCase toLowerCase =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toLowerCase](to-lower-case) **Platform and version requirements:** JVM (1.0), JS (1.0) ``` @DeprecatedSinceKotlin("1.5") fun Char.toLowerCase(): Char ``` **Deprecated:** Use lowercaseChar() instead. Converts this character to lower case using Unicode mapping rules of the invariant locale. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") fun String.toLowerCase(): String ``` **Deprecated:** Use lowercase() instead. Returns a copy of this string converted to lower case using the rules of the default locale. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.5") fun String.toLowerCase(     locale: Locale ): String ``` **Deprecated:** Use lowercase() instead. Returns a copy of this string converted to lower case using the rules of the specified locale. kotlin firstOrNull firstOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [firstOrNull](first-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.firstOrNull(): Char? ``` Returns the first character, or `null` if the char sequence is empty. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.firstOrNull(     predicate: (Char) -> Boolean ): Char? ``` Returns the first character matching the given [predicate](first-or-null#kotlin.text%24firstOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if character was not found. kotlin intern intern ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <intern> **Platform and version requirements:** JVM (1.0) ``` fun String.intern(): String ``` Returns a canonical representation for this string object. kotlin replaceFirstChar replaceFirstChar ================ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [replaceFirstChar](replace-first-char) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("replaceFirstCharWithChar") inline fun String.replaceFirstChar(     transform: (Char) -> Char ): String ``` ``` @JvmName("replaceFirstCharWithCharSequence") inline fun String.replaceFirstChar(     transform: (Char) -> CharSequence ): String ``` Returns a copy of this string having its first character replaced with the result of the specified [transform](replace-first-char#kotlin.text%24replaceFirstChar(kotlin.String,%20kotlin.Function1((kotlin.Char,%20)))/transform), or the original string if it's empty. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart println("kotlin".replaceFirstChar { it.uppercase() }) // Kotlin val sentence = "Welcome to Kotlin!" val words = sentence.split(' '); println(words.joinToString(separator = "_") { word -> word.replaceFirstChar { it.lowercase() } }) // welcome_to_kotlin! //sampleEnd } ``` Parameters ---------- `transform` - function that takes the first character and returns the result of the transform applied to the character. kotlin toDoubleOrNull toDoubleOrNull ============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toDoubleOrNull](to-double-or-null) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun String.toDoubleOrNull(): Double? ``` Parses the string as a [Double](../kotlin/-double/index#kotlin.Double) number and returns the result or `null` if the string is not a valid representation of a number. kotlin replaceFirst replaceFirst ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [replaceFirst](replace-first) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceFirst(     oldChar: Char,     newChar: Char,     ignoreCase: Boolean = false ): String ``` Returns a new string with the first occurrence of [oldChar](replace-first#kotlin.text%24replaceFirst(kotlin.String,%20kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/oldChar) replaced with [newChar](replace-first#kotlin.text%24replaceFirst(kotlin.String,%20kotlin.Char,%20kotlin.Char,%20kotlin.Boolean)/newChar). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.replaceFirst(     oldValue: String,     newValue: String,     ignoreCase: Boolean = false ): String ``` Returns a new string obtained by replacing the first occurrence of the [oldValue](replace-first#kotlin.text%24replaceFirst(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.Boolean)/oldValue) substring in this string with the specified [newValue](replace-first#kotlin.text%24replaceFirst(kotlin.String,%20kotlin.String,%20kotlin.String,%20kotlin.Boolean)/newValue) string. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.replaceFirst(     regex: Regex,     replacement: String ): String ``` Replaces the first occurrence of the given regular expression [regex](replace-first#kotlin.text%24replaceFirst(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/regex) in this char sequence with specified [replacement](replace-first#kotlin.text%24replaceFirst(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/replacement) expression. Parameters ---------- `replacement` - A replacement expression that can include substitutions. See [Regex.replaceFirst](-regex/replace-first#kotlin.text.Regex%24replaceFirst(kotlin.CharSequence,%20kotlin.String)) for details.
programming_docs
kotlin maxOf maxOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [maxOf](max-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun CharSequence.maxOf(     selector: (Char) -> Double ): Double ``` ``` inline fun CharSequence.maxOf(     selector: (Char) -> Float ): Float ``` Returns the largest value among all values produced by [selector](max-of#kotlin.text%24maxOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence. If any of values produced by [selector](max-of#kotlin.text%24maxOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <R : Comparable<R>> CharSequence.maxOf(     selector: (Char) -> R ): R ``` Returns the largest value among all values produced by [selector](max-of#kotlin.text%24maxOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.maxOf.R)))/selector) function applied to each character in the char sequence. Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. kotlin titlecase titlecase ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <titlecase> **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Char.titlecase(): String ``` Converts this character to title case using Unicode mapping rules of the invariant locale. This function supports one-to-many character mapping, thus the length of the returned string can be greater than one. For example, `'\uFB00'.titlecase()` returns `"\u0046\u0066"`, where `'\uFB00'` is the LATIN SMALL LIGATURE FF character (`ff`). If this character has no title case mapping, the result of [uppercase](uppercase#kotlin.text%24uppercase(kotlin.Char)) is returned instead. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('a', 'Dž', 'ʼn', '+', 'ß') val titlecaseChar = chars.map { it.titlecaseChar() } val titlecase = chars.map { it.titlecase() } println(titlecaseChar) // [A, Dž, ʼn, +, ß] println(titlecase) // [A, Dž, ʼN, +, Ss] //sampleEnd } ``` **Platform and version requirements:** JVM (1.5) ``` fun Char.titlecase(locale: Locale): String ``` Converts this character to title case using Unicode mapping rules of the specified [locale](titlecase#kotlin.text%24titlecase(kotlin.Char,%20java.util.Locale)/locale). This function supports one-to-many character mapping, thus the length of the returned string can be greater than one. For example, `'\uFB00'.titlecase(Locale.US)` returns `"\u0046\u0066"`, where `'\uFB00'` is the LATIN SMALL LIGATURE FF character (`ff`). If this character has no title case mapping, the result of `uppercase(locale)` is returned instead. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('a', 'Dž', 'ʼn', '+', 'ß', 'i') val titlecase = chars.map { it.titlecase() } val turkishLocale = Locale.forLanguageTag("tr") val titlecaseTurkish = chars.map { it.titlecase(turkishLocale) } println(titlecase) // [A, Dž, ʼN, +, Ss, I] println(titlecaseTurkish) // [A, Dž, ʼN, +, Ss, İ] //sampleEnd } ``` kotlin singleOrNull singleOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [singleOrNull](single-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.singleOrNull(): Char? ``` Returns single character, or `null` if the char sequence is empty or has more than one character. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.singleOrNull(     predicate: (Char) -> Boolean ): Char? ``` Returns the single character matching the given [predicate](single-or-null#kotlin.text%24singleOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if character was not found or more than one character was found. kotlin encodeToByteArray encodeToByteArray ================= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [encodeToByteArray](encode-to-byte-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun String.encodeToByteArray(): ByteArray ``` Encodes this string to an array of bytes in UTF-8 encoding. Any malformed char sequence is replaced by the replacement byte sequence. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun String.encodeToByteArray(     startIndex: Int = 0,     endIndex: Int = this.length,     throwOnInvalidSequence: Boolean = false ): ByteArray ``` Encodes this string or its substring to an array of bytes in UTF-8 encoding. Parameters ---------- `startIndex` - the beginning (inclusive) of the substring to encode, 0 by default. `endIndex` - the end (exclusive) of the substring to encode, length of this string by default. `throwOnInvalidSequence` - specifies whether to throw an exception on malformed char sequence or replace. Exceptions ---------- `IndexOutOfBoundsException` - if [startIndex](encode-to-byte-array#kotlin.text%24encodeToByteArray(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/startIndex) is less than zero or [endIndex](encode-to-byte-array#kotlin.text%24encodeToByteArray(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/endIndex) is greater than the length of this string. `IllegalArgumentException` - if [startIndex](encode-to-byte-array#kotlin.text%24encodeToByteArray(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/startIndex) is greater than [endIndex](encode-to-byte-array#kotlin.text%24encodeToByteArray(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/endIndex). `CharacterCodingException` - if this string contains malformed char sequence and [throwOnInvalidSequence](encode-to-byte-array#kotlin.text%24encodeToByteArray(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/throwOnInvalidSequence) is true. kotlin zip zip === [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <zip> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun CharSequence.zip(     other: CharSequence ): List<Pair<Char, Char>> ``` Returns a list of pairs built from the characters of `this` and the [other](zip#kotlin.text%24zip(kotlin.CharSequence,%20kotlin.CharSequence)/other) char sequences with the same index The returned list has length of the shortest char sequence. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val stringA = "abcd" val stringB = "zyx" println(stringA zip stringB) // [(a, z), (b, y), (c, x)] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <V> CharSequence.zip(     other: CharSequence,     transform: (a: Char, b: Char) -> V ): List<V> ``` Returns a list of values built from the characters of `this` and the [other](zip#kotlin.text%24zip(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20kotlin.text.zip.V)))/other) char sequences with the same index using the provided [transform](zip#kotlin.text%24zip(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20kotlin.text.zip.V)))/transform) function applied to each pair of characters. The returned list has length of the shortest char sequence. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val stringA = "abcd" val stringB = "zyx" val result = stringA.zip(stringB) { a, b -> "$a$b" } println(result) // [az, by, cx] //sampleEnd } ``` kotlin randomOrNull randomOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [randomOrNull](random-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharSequence.randomOrNull(): Char? ``` Returns a random character from this char sequence, or `null` if this char sequence is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharSequence.randomOrNull(random: Random): Char? ``` Returns a random character from this char sequence using the specified source of randomness, or `null` if this char sequence is empty. kotlin digitToIntOrNull digitToIntOrNull ================ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [digitToIntOrNull](digit-to-int-or-null) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Char.digitToIntOrNull(): Int? ``` Returns the numeric value of the decimal digit that this Char represents, or `null` if this Char is not a valid decimal digit. A Char is considered to represent a decimal digit if [isDigit](is-digit#kotlin.text%24isDigit(kotlin.Char)) is true for the Char. In this case, the Unicode decimal digit value of the character is returned. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart println('5'.digitToIntOrNull()) // 5 println('3'.digitToIntOrNull(radix = 8)) // 3 println('A'.digitToIntOrNull(radix = 16)) // 10 println('K'.digitToIntOrNull(radix = 36)) // 20 // radix argument should be in 2..36 // '0'.digitToIntOrNull(radix = 1) // will fail // '1'.digitToIntOrNull(radix = 100) // will fail // only 0 and 1 digits are valid for binary numbers println('5'.digitToIntOrNull(radix = 2)) // null // radix = 10 is used by default println('A'.digitToIntOrNull()) // null // symbol '+' is not a digit in any radix println('+'.digitToIntOrNull()) // null // Only Latin letters are valid for digits greater than 9. println('β'.digitToIntOrNull(radix = 36)) // null //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Char.digitToIntOrNull(radix: Int): Int? ``` Returns the numeric value of the digit that this Char represents in the specified [radix](digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix), or `null` if this Char is not a valid digit in the specified [radix](digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix). Throws an exception if the [radix](digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix) is not in the range `2..36`. A Char is considered to represent a digit in the specified [radix](digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix) if at least one of the following is true: * [isDigit](is-digit#kotlin.text%24isDigit(kotlin.Char)) is `true` for the Char and the Unicode decimal digit value of the character is less than the specified [radix](digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix). In this case the decimal digit value is returned. * The Char is one of the uppercase Latin letters 'A' through 'Z' and its [code](../kotlin/code) is less than `radix + 'A'.code - 10`. In this case, `this.code - 'A'.code + 10` is returned. * The Char is one of the lowercase Latin letters 'a' through 'z' and its [code](../kotlin/code) is less than `radix + 'a'.code - 10`. In this case, `this.code - 'a'.code + 10` is returned. * The Char is one of the fullwidth Latin capital letters '\uFF21' through '\uFF3A' and its [code](../kotlin/code) is less than `radix + 0xFF21 - 10`. In this case, `this.code - 0xFF21 + 10` is returned. * The Char is one of the fullwidth Latin small letters '\uFF41' through '\uFF5A' and its [code](../kotlin/code) is less than `radix + 0xFF41 - 10`. In this case, `this.code - 0xFF41 + 10` is returned. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart println('5'.digitToIntOrNull()) // 5 println('3'.digitToIntOrNull(radix = 8)) // 3 println('A'.digitToIntOrNull(radix = 16)) // 10 println('K'.digitToIntOrNull(radix = 36)) // 20 // radix argument should be in 2..36 // '0'.digitToIntOrNull(radix = 1) // will fail // '1'.digitToIntOrNull(radix = 100) // will fail // only 0 and 1 digits are valid for binary numbers println('5'.digitToIntOrNull(radix = 2)) // null // radix = 10 is used by default println('A'.digitToIntOrNull()) // null // symbol '+' is not a digit in any radix println('+'.digitToIntOrNull()) // null // Only Latin letters are valid for digits greater than 9. println('β'.digitToIntOrNull(radix = 36)) // null //sampleEnd } ``` kotlin takeLast takeLast ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [takeLast](take-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.takeLast(n: Int): CharSequence ``` Returns a subsequence of this char sequence containing the last [n](take-last#kotlin.text%24takeLast(kotlin.CharSequence,%20kotlin.Int)/n) characters from this char sequence, or the entire char sequence if this char sequence is shorter. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.take(8)) // <<<First println(string.takeLast(8)) // Grade>>> println(string.takeWhile { !it.isLetter() }) // <<< println(string.takeLastWhile { !it.isLetter() }) // >>> //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](take-last#kotlin.text%24takeLast(kotlin.CharSequence,%20kotlin.Int)/n) is negative. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.takeLast(n: Int): String ``` Returns a string containing the last [n](take-last#kotlin.text%24takeLast(kotlin.String,%20kotlin.Int)/n) characters from this string, or the entire string if this string is shorter. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.take(8)) // <<<First println(string.takeLast(8)) // Grade>>> println(string.takeWhile { !it.isLetter() }) // <<< println(string.takeLastWhile { !it.isLetter() }) // >>> //sampleEnd } ``` Exceptions ---------- `IllegalArgumentException` - if [n](take-last#kotlin.text%24takeLast(kotlin.String,%20kotlin.Int)/n) is negative. kotlin reduceRight reduceRight =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [reduceRight](reduce-right) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.reduceRight(     operation: (Char, acc: Char) -> Char ): Char ``` Accumulates value starting with the last character and applying [operation](reduce-right#kotlin.text%24reduceRight(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from right to left to each character and current accumulator value. Throws an exception if this char sequence is empty. If the char sequence can be empty in an expected way, please use [reduceRightOrNull](reduce-right-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduceRight { string, acc -> acc + string }) // dcba println(strings.reduceRightIndexed { index, string, acc -> acc + string + index }) // dc2b1a0 // emptyList<Int>().reduceRight { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes a character and current accumulator value, and calculates the next accumulator value. kotlin groupBy groupBy ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [groupBy](group-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K> CharSequence.groupBy(     keySelector: (Char) -> K ): Map<K, List<Char>> ``` Groups characters of the original char sequence by the key returned by the given [keySelector](group-by#kotlin.text%24groupBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.K)))/keySelector) function applied to each character and returns a map where each group key is associated with a list of corresponding characters. The returned map preserves the entry iteration order of the keys produced from the original char sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val words = listOf("a", "abc", "ab", "def", "abcd") val byLength = words.groupBy { it.length } println(byLength.keys) // [1, 3, 2, 4] println(byLength.values) // [[a], [abc, def], [ab], [abcd]] val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } // same content as in byLength map, but the map is mutable println("mutableByLength == byLength is ${mutableByLength == byLength}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <K, V> CharSequence.groupBy(     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): Map<K, List<V>> ``` Groups values returned by the [valueTransform](group-by#kotlin.text%24groupBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.V)))/valueTransform) function applied to each character of the original char sequence by the key returned by the given [keySelector](group-by#kotlin.text%24groupBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupBy.V)))/keySelector) function applied to the character and returns a map where each group key is associated with a list of corresponding values. The returned map preserves the entry iteration order of the keys produced from the original char sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing") val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first }) println(namesByTeam) // {Marketing=[Alice, Carol], Sales=[Bob]} val mutableNamesByTeam = nameToTeam.groupByTo(HashMap(), { it.second }, { it.first }) // same content as in namesByTeam map, but the map is mutable println("mutableNamesByTeam == namesByTeam is ${mutableNamesByTeam == namesByTeam}") // true //sampleEnd } ``` kotlin takeWhile takeWhile ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [takeWhile](take-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.takeWhile(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a subsequence of this char sequence containing the first characters that satisfy the given [predicate](take-while#kotlin.text%24takeWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.take(8)) // <<<First println(string.takeLast(8)) // Grade>>> println(string.takeWhile { !it.isLetter() }) // <<< println(string.takeLastWhile { !it.isLetter() }) // >>> //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun String.takeWhile(     predicate: (Char) -> Boolean ): String ``` Returns a string containing the first characters that satisfy the given [predicate](take-while#kotlin.text%24takeWhile(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.take(8)) // <<<First println(string.takeLast(8)) // Grade>>> println(string.takeWhile { !it.isLetter() }) // <<< println(string.takeLastWhile { !it.isLetter() }) // >>> //sampleEnd } ```
programming_docs
kotlin sumOf sumOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [sumOf](sum-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfDouble") inline fun CharSequence.sumOf(     selector: (Char) -> Double ): Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfInt") inline fun CharSequence.sumOf(     selector: (Char) -> Int ): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @JvmName("sumOfLong") inline fun CharSequence.sumOf(     selector: (Char) -> Long ): Long ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfUInt") inline fun CharSequence.sumOf(     selector: (Char) -> UInt ): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` @JvmName("sumOfULong") inline fun CharSequence.sumOf(     selector: (Char) -> ULong ): ULong ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigDecimal") inline fun CharSequence.sumOf(     selector: (Char) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("sumOfBigInteger") inline fun CharSequence.sumOf(     selector: (Char) -> BigInteger ): BigInteger ``` Returns the sum of all values produced by [selector](sum-of#kotlin.text%24sumOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence. kotlin toHashSet toHashSet ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toHashSet](to-hash-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.toHashSet(): HashSet<Char> ``` Returns a new [HashSet](../kotlin.collections/-hash-set/index#kotlin.collections.HashSet) of all characters. kotlin toBoolean toBoolean ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toBoolean](to-boolean) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.4") fun String.toBoolean(): Boolean ``` **Deprecated:** Use Kotlin compiler 1.4 to avoid deprecation warning. Returns `true` if the content of this string is equal to the word "true", ignoring case, and `false` otherwise. **Platform and version requirements:** JS (1.4), Native (1.4) ``` fun String?.toBoolean(): Boolean ``` **Platform and version requirements:** JVM (1.4) ``` @JvmName("toBooleanNullable") fun String?.toBoolean(): Boolean ``` ##### For Common, JS, Native Returns `true` if this string is not `null` and its content is equal to the word "true", ignoring case, and `false` otherwise. There are also strict versions of the function available on non-nullable String, [toBooleanStrict](to-boolean-strict) and [toBooleanStrictOrNull](to-boolean-strict-or-null). ##### For JVM Returns `true` if this string is not `null` and its content is equal to the word "true", ignoring case, and `false` otherwise. There are also strict versions of the function available on non-nullable String, toBooleanStrict and toBooleanStrictOrNull. kotlin trim trim ==== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <trim> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.trim(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a sub sequence of this char sequence having leading and trailing characters matching the [predicate](trim#kotlin.text%24trim(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun String.trim(predicate: (Char) -> Boolean): String ``` Returns a string having leading and trailing characters matching the [predicate](trim#kotlin.text%24trim(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.trim(vararg chars: Char): CharSequence ``` Returns a sub sequence of this char sequence having leading and trailing characters from the [chars](trim#kotlin.text%24trim(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.trim(vararg chars: Char): String ``` Returns a string having leading and trailing characters from the [chars](trim#kotlin.text%24trim(kotlin.String,%20kotlin.CharArray)/chars) array removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.trim(): CharSequence ``` Returns a sub sequence of this char sequence having leading and trailing whitespace removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.trim(): String ``` Returns a string having leading and trailing whitespace removed. kotlin toDouble toDouble ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun String.toDouble(): Double ``` Parses the string as a [Double](../kotlin/-double/index#kotlin.Double) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. kotlin toSortedSet toSortedSet =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toSortedSet](to-sorted-set) **Platform and version requirements:** JVM (1.0) ``` fun CharSequence.toSortedSet(): SortedSet<Char> ``` Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all characters. kotlin maxWith maxWith ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [maxWith](max-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("maxWithOrThrow") fun CharSequence.maxWith(     comparator: Comparator<in Char> ): Char ``` Returns the first character having the largest value according to the provided [comparator](max-with#kotlin.text%24maxWith(kotlin.CharSequence,%20kotlin.Comparator((kotlin.Char)))/comparator). Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun CharSequence.maxWith(     comparator: Comparator<in Char> ): Char? ``` **Deprecated:** Use maxWithOrNull instead. kotlin filterTo filterTo ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [filterTo](filter-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <C : Appendable> CharSequence.filterTo(     destination: C,     predicate: (Char) -> Boolean ): C ``` Appends all characters matching the given [predicate](filter-to#kotlin.text%24filterTo(kotlin.CharSequence,%20kotlin.text.filterTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](filter-to#kotlin.text%24filterTo(kotlin.CharSequence,%20kotlin.text.filterTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/destination). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7) val evenNumbers = mutableListOf<Int>() val notMultiplesOf3 = mutableListOf<Int>() println(evenNumbers) // [] numbers.filterTo(evenNumbers) { it % 2 == 0 } numbers.filterNotTo(notMultiplesOf3) { number -> number % 3 == 0 } println(evenNumbers) // [2, 4, 6] println(notMultiplesOf3) // [1, 2, 4, 5, 7] //sampleEnd } ``` kotlin flatMap flatMap ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [flatMap](flat-map) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R> CharSequence.flatMap(     transform: (Char) -> Iterable<R> ): List<R> ``` Returns a single list of all elements yielded from results of [transform](flat-map#kotlin.text%24flatMap(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMap.R)))))/transform) function being invoked on each character of original char sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("123", "45") println(list.flatMap { it.toList() }) // [1, 2, 3, 4, 5] //sampleEnd } ``` kotlin minBy minBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [minBy](min-by) **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minByOrThrow") inline fun <R : Comparable<R>> CharSequence.minBy(     selector: (Char) -> R ): Char ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> CharSequence.minBy(     selector: (Char) -> R ): Char? ``` **Deprecated:** Use minByOrNull instead. Returns the first character yielding the smallest value of the given function. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.minBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. kotlin lowercaseChar lowercaseChar ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [lowercaseChar](lowercase-char) **Platform and version requirements:** JVM (1.5), JS (1.5) ``` fun Char.lowercaseChar(): Char ``` Converts this character to lower case using Unicode mapping rules of the invariant locale. This function performs one-to-one character mapping. To support one-to-many character mapping use the [lowercase](lowercase#kotlin.text%24lowercase(kotlin.Char)) function. If this character has no mapping equivalent, the character itself is returned. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('A', 'Ω', '1', 'a', '+', 'İ') val lowercaseChar = chars.map { it.lowercaseChar() } val lowercase = chars.map { it.lowercase() } println(lowercaseChar) // [a, ω, 1, a, +, i] println(lowercase) // [a, ω, 1, a, +, \u0069\u0307] //sampleEnd } ``` kotlin toByteArray toByteArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toByteArray](to-byte-array) **Platform and version requirements:** JVM (1.0) ``` fun String.toByteArray(     charset: Charset = Charsets.UTF_8 ): ByteArray ``` Encodes the contents of this string using the specified character set and returns the resulting byte array. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val charset = Charsets.UTF_8 val byteArray = "Hello".toByteArray(charset) println(byteArray.contentToString()) // [72, 101, 108, 108, 111] println(byteArray.toString(charset)) // Hello //sampleEnd } ``` kotlin dropWhile dropWhile ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [dropWhile](drop-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.dropWhile(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a subsequence of this char sequence containing all characters except first characters that satisfy the given [predicate](drop-while#kotlin.text%24dropWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.drop(6)) // st Grade>>> println(string.dropLast(6)) // <<<First Gr println(string.dropWhile { !it.isLetter() }) // First Grade>>> println(string.dropLastWhile { !it.isLetter() }) // <<<First Grade //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun String.dropWhile(     predicate: (Char) -> Boolean ): String ``` Returns a string containing all characters except first characters that satisfy the given [predicate](drop-while#kotlin.text%24dropWhile(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.drop(6)) // st Grade>>> println(string.dropLast(6)) // <<<First Gr println(string.dropWhile { !it.isLetter() }) // First Grade>>> println(string.dropLastWhile { !it.isLetter() }) // <<<First Grade //sampleEnd } ``` kotlin isJavaIdentifierStart isJavaIdentifierStart ===================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isJavaIdentifierStart](is-java-identifier-start) **Platform and version requirements:** JVM (1.0) ``` fun Char.isJavaIdentifierStart(): Boolean ``` Returns `true` if this character is permissible as the first character in a Java identifier. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('a', '_', 'β', '$', '1', '+', ';') val (javaIdentifierStarts, notJavaIdentifierStarts) = chars.partition { it.isJavaIdentifierStart() } println(javaIdentifierStarts) // [a, _, β, $] println(notJavaIdentifierStarts) // [1, +, ;] //sampleEnd } ``` kotlin toUIntOrNull toUIntOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toUIntOrNull](to-u-int-or-null) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun String.toUIntOrNull(): UInt? ``` Parses the string as an [UInt](../kotlin/-u-int/index) number and returns the result or `null` if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun String.toUIntOrNull(radix: Int): UInt? ``` Parses the string as an [UInt](../kotlin/-u-int/index) number and returns the result or `null` if the string is not a valid representation of a number. Exceptions ---------- `IllegalArgumentException` - when [radix](to-u-int-or-null#kotlin.text%24toUIntOrNull(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin find find ==== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <find> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.find(     predicate: (Char) -> Boolean ): Char? ``` Returns the first character matching the given [predicate](find#kotlin.text%24find(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if no such character was found. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val numbers = listOf(1, 2, 3, 4, 5, 6, 7) val firstOdd = numbers.find { it % 2 != 0 } val lastEven = numbers.findLast { it % 2 == 0 } println(firstOdd) // 1 println(lastEven) // 6 //sampleEnd } ``` kotlin trimStart trimStart ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [trimStart](trim-start) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.trimStart(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a sub sequence of this char sequence having leading characters matching the [predicate](trim-start#kotlin.text%24trimStart(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun String.trimStart(     predicate: (Char) -> Boolean ): String ``` Returns a string having leading characters matching the [predicate](trim-start#kotlin.text%24trimStart(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.trimStart(vararg chars: Char): CharSequence ``` Returns a sub sequence of this char sequence having leading characters from the [chars](trim-start#kotlin.text%24trimStart(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.trimStart(vararg chars: Char): String ``` Returns a string having leading characters from the [chars](trim-start#kotlin.text%24trimStart(kotlin.String,%20kotlin.CharArray)/chars) array removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.trimStart(): CharSequence ``` Returns a sub sequence of this char sequence having leading whitespace removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.trimStart(): String ``` Returns a string having leading whitespace removed. kotlin digitToChar digitToChar =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [digitToChar](digit-to-char) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Int.digitToChar(): Char ``` Returns the Char that represents this decimal digit. Throws an exception if this value is not in the range `0..9`. If this value is in `0..9`, the decimal digit Char with code `'0'.code + this` is returned. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart println(5.digitToChar()) // 5 println(3.digitToChar(radix = 8)) // 3 println(10.digitToChar(radix = 16)) // A println(20.digitToChar(radix = 36)) // K // radix argument should be in 2..36 // 0.digitToChar(radix = 1) // will fail // 1.digitToChar(radix = 100) // will fail // only 0 and 1 digits are valid for binary numbers // 5.digitToChar(radix = 2) // will fail // radix = 10 is used by default // 10.digitToChar() // will fail // a negative integer is not a digit in any radix // (-1).digitToChar() // will fail //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Int.digitToChar(radix: Int): Char ``` Returns the Char that represents this numeric digit value in the specified [radix](digit-to-char#kotlin.text%24digitToChar(kotlin.Int,%20kotlin.Int)/radix). Throws an exception if the [radix](digit-to-char#kotlin.text%24digitToChar(kotlin.Int,%20kotlin.Int)/radix) is not in the range `2..36` or if this value is not in the range `0 until radix`. If this value is less than `10`, the decimal digit Char with code `'0'.code + this` is returned. Otherwise, the uppercase Latin letter with code `'A'.code + this - 10` is returned. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart println(5.digitToChar()) // 5 println(3.digitToChar(radix = 8)) // 3 println(10.digitToChar(radix = 16)) // A println(20.digitToChar(radix = 36)) // K // radix argument should be in 2..36 // 0.digitToChar(radix = 1) // will fail // 1.digitToChar(radix = 100) // will fail // only 0 and 1 digits are valid for binary numbers // 5.digitToChar(radix = 2) // will fail // radix = 10 is used by default // 10.digitToChar() // will fail // a negative integer is not a digit in any radix // (-1).digitToChar() // will fail //sampleEnd } ``` kotlin takeLastWhile takeLastWhile ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [takeLastWhile](take-last-while) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.takeLastWhile(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a subsequence of this char sequence containing last characters that satisfy the given [predicate](take-last-while#kotlin.text%24takeLastWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.take(8)) // <<<First println(string.takeLast(8)) // Grade>>> println(string.takeWhile { !it.isLetter() }) // <<< println(string.takeLastWhile { !it.isLetter() }) // >>> //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun String.takeLastWhile(     predicate: (Char) -> Boolean ): String ``` Returns a string containing last characters that satisfy the given [predicate](take-last-while#kotlin.text%24takeLastWhile(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "<<<First Grade>>>" println(string.take(8)) // <<<First println(string.takeLast(8)) // Grade>>> println(string.takeWhile { !it.isLetter() }) // <<< println(string.takeLastWhile { !it.isLetter() }) // >>> //sampleEnd } ```
programming_docs
kotlin elementAtOrNull elementAtOrNull =============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [elementAtOrNull](element-at-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.elementAtOrNull(index: Int): Char? ``` Returns a character at the given [index](element-at-or-null#kotlin.text%24elementAtOrNull(kotlin.CharSequence,%20kotlin.Int)/index) or `null` if the [index](element-at-or-null#kotlin.text%24elementAtOrNull(kotlin.CharSequence,%20kotlin.Int)/index) is out of bounds of this char sequence. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(1, 2, 3) println(list.elementAtOrNull(0)) // 1 println(list.elementAtOrNull(2)) // 3 println(list.elementAtOrNull(3)) // null val emptyList = emptyList<Int>() println(emptyList.elementAtOrNull(0)) // null //sampleEnd } ``` kotlin commonSuffixWith commonSuffixWith ================ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [commonSuffixWith](common-suffix-with) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.commonSuffixWith(     other: CharSequence,     ignoreCase: Boolean = false ): String ``` Returns the longest string `suffix` such that this char sequence and [other](common-suffix-with#kotlin.text%24commonSuffixWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) char sequence both end with this suffix, taking care not to split surrogate pairs. If this and [other](common-suffix-with#kotlin.text%24commonSuffixWith(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Boolean)/other) have no common suffix, returns the empty string. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart println("Hot_Tea".commonSuffixWith("iced_tea")) // ea println("Hot_Tea".commonSuffixWith("iced_tea", true)) // _Tea println("Hot_Tea".commonSuffixWith("Hot_Coffee")) // //sampleEnd } ``` Parameters ---------- `ignoreCase` - `true` to ignore character case when matching a character. By default `false`. kotlin substringBeforeLast substringBeforeLast =================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [substringBeforeLast](substring-before-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.substringBeforeLast(     delimiter: Char,     missingDelimiterValue: String = this ): String ``` ``` fun String.substringBeforeLast(     delimiter: String,     missingDelimiterValue: String = this ): String ``` Returns a substring before the last occurrence of [delimiter](substring-before-last#kotlin.text%24substringBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](substring-before-last#kotlin.text%24substringBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/missingDelimiterValue) which defaults to the original string. kotlin isNotEmpty isNotEmpty ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isNotEmpty](is-not-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.isNotEmpty(): Boolean ``` Returns `true` if this char sequence is not empty. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun markdownLink(title: String, url: String) = if (title.isNotEmpty()) "[$title]($url)" else url // plain link println(markdownLink(title = "", url = "https://kotlinlang.org")) // https://kotlinlang.org // link with custom title println(markdownLink(title = "Kotlin Language", url = "https://kotlinlang.org")) // [Kotlin Language](https://kotlinlang.org) //sampleEnd } ``` kotlin maxBy maxBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [maxBy](max-by) **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxByOrThrow") inline fun <R : Comparable<R>> CharSequence.maxBy(     selector: (Char) -> R ): Char ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> CharSequence.maxBy(     selector: (Char) -> R ): Char? ``` **Deprecated:** Use maxByOrNull instead. Returns the first character yielding the largest value of the given function. ``` fun main(args: Array<String>) { //sampleStart //Unresolved: samples.collections.Collections.Aggregates.maxBy //sampleEnd } ``` Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. kotlin CASE_INSENSITIVE_ORDER CASE\_INSENSITIVE\_ORDER ======================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [CASE\_INSENSITIVE\_ORDER](-c-a-s-e_-i-n-s-e-n-s-i-t-i-v-e_-o-r-d-e-r) **Platform and version requirements:** JVM (1.0), JS (1.2), Native (1.3) ``` val String.Companion.CASE_INSENSITIVE_ORDER: Comparator<String> ``` A Comparator that orders strings ignoring character case. Note that this Comparator does not take locale into account, and will result in an unsatisfactory ordering for certain locales. kotlin getOrElse getOrElse ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [getOrElse](get-or-else) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.getOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` Returns a character at the given [index](get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) or the result of calling the [defaultValue](get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) is out of bounds of this char sequence. kotlin appendLine appendLine ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [appendLine](append-line) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Appendable.appendLine(): Appendable ``` Appends a line feed character (`\n`) to this Appendable. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Appendable.appendLine(value: CharSequence?): Appendable ``` ``` fun Appendable.appendLine(value: Char): Appendable ``` Appends value to the given Appendable and a line feed character (`\n`) after it. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(): StringBuilder ``` Appends a line feed character (`\n`) to this StringBuilder. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(     value: CharSequence? ): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: String?): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: Any?): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: CharArray): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: Char): StringBuilder ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun StringBuilder.appendLine(value: Boolean): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Byte): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Short): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Int): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Long): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Float): StringBuilder ``` **Platform and version requirements:** Native (1.4) ``` fun StringBuilder.appendLine(value: Double): StringBuilder ``` Appends [value](append-line#kotlin.text%24appendLine(kotlin.text.StringBuilder,%20kotlin.CharSequence?)/value) to this [StringBuilder](-string-builder/index#kotlin.text.StringBuilder), followed by a line feed character (`\n`). kotlin toFloatOrNull toFloatOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toFloatOrNull](to-float-or-null) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun String.toFloatOrNull(): Float? ``` Parses the string as a [Float](../kotlin/-float/index#kotlin.Float) number and returns the result or `null` if the string is not a valid representation of a number. kotlin random random ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <random> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun CharSequence.random(): Char ``` Returns a random character from this char sequence. Exceptions ---------- `NoSuchElementException` - if this char sequence is empty. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun CharSequence.random(random: Random): Char ``` Returns a random character from this char sequence using the specified source of randomness. Exceptions ---------- `NoSuchElementException` - if this char sequence is empty. kotlin sumBy sumBy ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [sumBy](sum-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") inline fun CharSequence.sumBy(     selector: (Char) -> Int ): Int ``` **Deprecated:** Use sumOf instead. Returns the sum of all values produced by [selector](sum-by#kotlin.text%24sumBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Int)))/selector) function applied to each character in the char sequence. kotlin reduce reduce ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <reduce> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.reduce(     operation: (acc: Char, Char) -> Char ): Char ``` Accumulates value starting with the first character and applying [operation](reduce#kotlin.text%24reduce(kotlin.CharSequence,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each character. Throws an exception if this char sequence is empty. If the char sequence can be empty in an expected way, please use [reduceOrNull](reduce-or-null) instead. It returns `null` when its receiver is empty. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val strings = listOf("a", "b", "c", "d") println(strings.reduce { acc, string -> acc + string }) // abcd println(strings.reduceIndexed { index, acc, string -> acc + string + index }) // ab1c2d3 // emptyList<Int>().reduce { _, _ -> 0 } // will fail //sampleEnd } ``` Parameters ---------- `operation` - function that takes current accumulator value and a character, and calculates the next accumulator value. kotlin capitalize capitalize ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <capitalize> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @DeprecatedSinceKotlin("1.5") fun String.capitalize(): String ``` **Deprecated:** Use replaceFirstChar instead. Returns a copy of this string having its first letter titlecased using the rules of the default locale, or the original string if it's empty or already starts with a title case letter. The title case of a character is usually the same as its upper case with several exceptions. The particular list of characters with the special title case form depends on the underlying platform. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart println("abcd".capitalize()) // Abcd println("Abcd".capitalize()) // Abcd //sampleEnd } ``` **Platform and version requirements:** JVM (1.4) ``` @DeprecatedSinceKotlin("1.5") fun String.capitalize(     locale: Locale ): String ``` **Deprecated:** Use replaceFirstChar instead. Returns a copy of this string having its first letter titlecased using the rules of the specified [locale](capitalize#kotlin.text%24capitalize(kotlin.String,%20java.util.Locale)/locale), or the original string if it's empty or already starts with a title case letter. The title case of a character is usually the same as its upper case with several exceptions. The particular list of characters with the special title case form depends on the underlying platform. kotlin ifBlank ifBlank ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [ifBlank](if-blank) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <C, R> C.ifBlank(     defaultValue: () -> R ): R where C : CharSequence, C : R ``` Returns this char sequence if it is not empty and doesn't consist solely of whitespace characters, or the result of calling [defaultValue](if-blank#kotlin.text%24ifBlank(kotlin.text.ifBlank.C,%20kotlin.Function0((kotlin.text.ifBlank.R)))/defaultValue) function otherwise. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val blank = " " val blankOrNull: String? = blank.ifBlank { null } println(blankOrNull) // null val blankOrDefault = blank.ifBlank { "default" } println(blankOrDefault) // default val nonBlank = "abc" val sameString = nonBlank.ifBlank { "def" } println("nonBlank === sameString is ${nonBlank === sameString}") // true //sampleEnd } ``` kotlin contentEquals contentEquals ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [contentEquals](content-equals) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` infix fun CharSequence?.contentEquals(     other: CharSequence? ): Boolean ``` ##### For Common, JS, Native Returns `true` if the contents of this char sequence are equal to the contents of the specified [other](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?)/other), i.e. both char sequences contain the same number of the same characters in the same order. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val stringBuilder = StringBuilder() stringBuilder.append("Kot").append("lin") println(stringBuilder) // Kotlin println("stringBuilder contentEquals \"Kotlin\" is ${stringBuilder contentEquals "Kotlin"}") // true stringBuilder.setCharAt(0, 'k') println(stringBuilder) // kotlin println("\"Kotlin\".contentEquals(stringBuilder) is ${"Kotlin".contentEquals(stringBuilder)}") // false println("\"Kotlin\".contentEquals(stringBuilder, ignoreCase = true) is ${"Kotlin".contentEquals(stringBuilder, ignoreCase = true)}") // true //sampleEnd } ``` ##### For JVM Returns `true` if the contents of this char sequence are equal to the contents of the specified [other](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?)/other), i.e. both char sequences contain the same number of the same characters in the same order. If this [CharSequence](../kotlin/-char-sequence/index#kotlin.CharSequence) is a [String](../kotlin/-string/index#kotlin.String) and [other](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?)/other) is not `null` then this function behaves the same as [String.contentEquals](content-equals). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val stringBuilder = StringBuilder() stringBuilder.append("Kot").append("lin") println(stringBuilder) // Kotlin println("stringBuilder contentEquals \"Kotlin\" is ${stringBuilder contentEquals "Kotlin"}") // true stringBuilder.setCharAt(0, 'k') println(stringBuilder) // kotlin println("\"Kotlin\".contentEquals(stringBuilder) is ${"Kotlin".contentEquals(stringBuilder)}") // false println("\"Kotlin\".contentEquals(stringBuilder, ignoreCase = true) is ${"Kotlin".contentEquals(stringBuilder, ignoreCase = true)}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun CharSequence?.contentEquals(     other: CharSequence?,     ignoreCase: Boolean ): Boolean ``` ##### For Common, JS, Native Returns `true` if the contents of this char sequence are equal to the contents of the specified [other](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?,%20kotlin.Boolean)/other), optionally ignoring case difference. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val stringBuilder = StringBuilder() stringBuilder.append("Kot").append("lin") println(stringBuilder) // Kotlin println("stringBuilder contentEquals \"Kotlin\" is ${stringBuilder contentEquals "Kotlin"}") // true stringBuilder.setCharAt(0, 'k') println(stringBuilder) // kotlin println("\"Kotlin\".contentEquals(stringBuilder) is ${"Kotlin".contentEquals(stringBuilder)}") // false println("\"Kotlin\".contentEquals(stringBuilder, ignoreCase = true) is ${"Kotlin".contentEquals(stringBuilder, ignoreCase = true)}") // true //sampleEnd } ``` Parameters ---------- `ignoreCase` - `true` to ignore character case when comparing contents. ##### For JVM Returns `true` if the contents of this char sequence are equal to the contents of the specified [other](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?,%20kotlin.Boolean)/other), optionally ignoring case difference. If this [CharSequence](../kotlin/-char-sequence/index#kotlin.CharSequence) is a [String](../kotlin/-string/index#kotlin.String), [other](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?,%20kotlin.Boolean)/other) is not `null` and [ignoreCase](content-equals#kotlin.text%24contentEquals(kotlin.CharSequence?,%20kotlin.CharSequence?,%20kotlin.Boolean)/ignoreCase) is `false` then this function behaves the same as [String.contentEquals](content-equals). ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val stringBuilder = StringBuilder() stringBuilder.append("Kot").append("lin") println(stringBuilder) // Kotlin println("stringBuilder contentEquals \"Kotlin\" is ${stringBuilder contentEquals "Kotlin"}") // true stringBuilder.setCharAt(0, 'k') println(stringBuilder) // kotlin println("\"Kotlin\".contentEquals(stringBuilder) is ${"Kotlin".contentEquals(stringBuilder)}") // false println("\"Kotlin\".contentEquals(stringBuilder, ignoreCase = true) is ${"Kotlin".contentEquals(stringBuilder, ignoreCase = true)}") // true //sampleEnd } ``` Parameters ---------- `ignoreCase` - `true` to ignore character case when comparing contents. **Platform and version requirements:** JVM (1.0) ``` fun String.contentEquals(charSequence: CharSequence): Boolean ``` Returns `true` if this string is equal to the contents of the specified [CharSequence](../kotlin/-char-sequence/index#kotlin.CharSequence), `false` otherwise. Note that if the [CharSequence](../kotlin/-char-sequence/index#kotlin.CharSequence) argument is a [StringBuffer](https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html) then the comparison may be performed in a synchronized block that acquires that [StringBuffer](https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html)'s monitor. **Platform and version requirements:** JVM (1.0) ``` fun String.contentEquals(     stringBuilder: StringBuffer ): Boolean ``` Returns `true` if this string is equal to the contents of the specified [StringBuffer](https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html), `false` otherwise. This function compares this string and the specified [StringBuffer](https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html) in a synchronized block that acquires that [StringBuffer](https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html)'s monitor.
programming_docs
kotlin toUByteOrNull toUByteOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toUByteOrNull](to-u-byte-or-null) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun String.toUByteOrNull(): UByte? ``` Parses the string as an [UByte](../kotlin/-u-byte/index) number and returns the result or `null` if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun String.toUByteOrNull(radix: Int): UByte? ``` Parses the string as an [UByte](../kotlin/-u-byte/index) number and returns the result or `null` if the string is not a valid representation of a number. Exceptions ---------- `IllegalArgumentException` - when [radix](to-u-byte-or-null#kotlin.text%24toUByteOrNull(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin slice slice ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <slice> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.slice(indices: IntRange): CharSequence ``` Returns a char sequence containing characters of the original char sequence at the specified range of [indices](slice#kotlin.text%24slice(kotlin.CharSequence,%20kotlin.ranges.IntRange)/indices). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.slice(indices: IntRange): String ``` Returns a string containing characters of the original string at the specified range of [indices](slice#kotlin.text%24slice(kotlin.String,%20kotlin.ranges.IntRange)/indices). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.slice(indices: Iterable<Int>): CharSequence ``` Returns a char sequence containing characters of the original char sequence at specified [indices](slice#kotlin.text%24slice(kotlin.CharSequence,%20kotlin.collections.Iterable((kotlin.Int)))/indices). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.slice(indices: Iterable<Int>): String ``` Returns a string containing characters of the original string at specified [indices](slice#kotlin.text%24slice(kotlin.String,%20kotlin.collections.Iterable((kotlin.Int)))/indices). kotlin toCollection toCollection ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toCollection](to-collection) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <C : MutableCollection<in Char>> CharSequence.toCollection(     destination: C ): C ``` Appends all characters to the given [destination](to-collection#kotlin.text%24toCollection(kotlin.CharSequence,%20kotlin.text.toCollection.C)/destination) collection. kotlin maxOfOrNull maxOfOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [maxOfOrNull](max-of-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun CharSequence.maxOfOrNull(     selector: (Char) -> Double ): Double? ``` ``` inline fun CharSequence.maxOfOrNull(     selector: (Char) -> Float ): Float? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.text%24maxOfOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence or `null` if there are no characters. If any of values produced by [selector](max-of-or-null#kotlin.text%24maxOfOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <R : Comparable<R>> CharSequence.maxOfOrNull(     selector: (Char) -> R ): R? ``` Returns the largest value among all values produced by [selector](max-of-or-null#kotlin.text%24maxOfOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.maxOfOrNull.R)))/selector) function applied to each character in the char sequence or `null` if there are no characters. kotlin firstNotNullOfOrNull firstNotNullOfOrNull ==================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [firstNotNullOfOrNull](first-not-null-of-or-null) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline fun <R : Any> CharSequence.firstNotNullOfOrNull(     transform: (Char) -> R? ): R? ``` Returns the first non-null value produced by [transform](first-not-null-of-or-null#kotlin.text%24firstNotNullOfOrNull(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.firstNotNullOfOrNull.R?)))/transform) function being applied to characters of this char sequence in iteration order, or `null` if no non-null value was produced. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart data class Rectangle(val height: Int, val width: Int) { val area: Int get() = height * width } val rectangles = listOf( Rectangle(3, 4), Rectangle(1, 8), Rectangle(6, 3), Rectangle(4, 3), Rectangle(5, 7) ) val largeArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 15 } } val largeAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 15 } } println(largeArea) // 18 println(largeAreaOrNull) // 18 // val evenLargerArea = rectangles.firstNotNullOf { it.area.takeIf { area -> area >= 50 } } // will fail with NoSuchElementException val evenLargerAreaOrNull = rectangles.firstNotNullOfOrNull { it.area.takeIf { area -> area >= 50 } } println(evenLargerAreaOrNull) // null //sampleEnd } ``` kotlin toBigDecimalOrNull toBigDecimalOrNull ================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toBigDecimalOrNull](to-big-decimal-or-null) **Platform and version requirements:** JVM (1.2) ``` fun String.toBigDecimalOrNull(): BigDecimal? ``` Parses the string as a [java.math.BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) number and returns the result or `null` if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.2) ``` fun String.toBigDecimalOrNull(     mathContext: MathContext ): BigDecimal? ``` Parses the string as a [java.math.BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) number and returns the result or `null` if the string is not a valid representation of a number. Parameters ---------- `mathContext` - specifies the precision and the rounding mode. Exceptions ---------- `ArithmeticException` - if the rounding is needed, but the rounding mode is [java.math.RoundingMode.UNNECESSARY](https://docs.oracle.com/javase/8/docs/api/java/math/RoundingMode.html#UNNECESSARY). kotlin iterator iterator ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun CharSequence.iterator(): CharIterator ``` Iterator for characters of the given char sequence. kotlin minWith minWith ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [minWith](min-with) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @JvmName("minWithOrThrow") fun CharSequence.minWith(     comparator: Comparator<in Char> ): Char ``` Returns the first character having the smallest value according to the provided [comparator](min-with#kotlin.text%24minWith(kotlin.CharSequence,%20kotlin.Comparator((kotlin.Char)))/comparator). Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun CharSequence.minWith(     comparator: Comparator<in Char> ): Char? ``` **Deprecated:** Use minWithOrNull instead. kotlin minOf minOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [minOf](min-of) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun CharSequence.minOf(     selector: (Char) -> Double ): Double ``` ``` inline fun CharSequence.minOf(     selector: (Char) -> Float ): Float ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.text%24minOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each character in the char sequence. If any of values produced by [selector](min-of#kotlin.text%24minOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function is `NaN`, the returned result is `NaN`. Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <R : Comparable<R>> CharSequence.minOf(     selector: (Char) -> R ): R ``` Returns the smallest value among all values produced by [selector](min-of#kotlin.text%24minOf(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.minOf.R)))/selector) function applied to each character in the char sequence. Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. kotlin isWhitespace isWhitespace ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isWhitespace](is-whitespace) **Platform and version requirements:** JVM (1.0), JS (1.1) ``` fun Char.isWhitespace(): Boolean ``` Determines whether a character is whitespace according to the Unicode standard. Returns `true` if the character is whitespace. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf(' ', '\t', '\n', '1', 'a', '\u00A0') val (whitespaces, notWhitespaces) = chars.partition { it.isWhitespace() } // whitespace char codes println(whitespaces.map(Char::code)) // [32, 9, 10, 160] // non-whitespace chars println(notWhitespaces) // [1, a] //sampleEnd } ``` kotlin toShortOrNull toShortOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toShortOrNull](to-short-or-null) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun String.toShortOrNull(): Short? ``` Parses the string as a [Short](../kotlin/-short/index#kotlin.Short) number and returns the result or `null` if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun String.toShortOrNull(radix: Int): Short? ``` Parses the string as a [Short](../kotlin/-short/index#kotlin.Short) number and returns the result or `null` if the string is not a valid representation of a number. Exceptions ---------- `IllegalArgumentException` - when [radix](to-short-or-null#kotlin.text%24toShortOrNull(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin toString toString ======== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toString](to-string) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun Byte.toString(radix: Int): String ``` Returns a string representation of this [Byte](../kotlin/-byte/index#kotlin.Byte) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.Byte,%20kotlin.Int)/radix). Exceptions ---------- `IllegalArgumentException` - when [radix](to-string#kotlin.text%24toString(kotlin.Byte,%20kotlin.Int)/radix) is not a valid radix for number to string conversion. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun Short.toString(radix: Int): String ``` Returns a string representation of this [Short](../kotlin/-short/index#kotlin.Short) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.Short,%20kotlin.Int)/radix). Exceptions ---------- `IllegalArgumentException` - when [radix](to-string#kotlin.text%24toString(kotlin.Short,%20kotlin.Int)/radix) is not a valid radix for number to string conversion. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun Int.toString(radix: Int): String ``` Returns a string representation of this [Int](../kotlin/-int/index#kotlin.Int) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.Int,%20kotlin.Int)/radix). Exceptions ---------- `IllegalArgumentException` - when [radix](to-string#kotlin.text%24toString(kotlin.Int,%20kotlin.Int)/radix) is not a valid radix for number to string conversion. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun Long.toString(radix: Int): String ``` Returns a string representation of this [Long](../kotlin/-long/index#kotlin.Long) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.Long,%20kotlin.Int)/radix). Exceptions ---------- `IllegalArgumentException` - when [radix](to-string#kotlin.text%24toString(kotlin.Long,%20kotlin.Int)/radix) is not a valid radix for number to string conversion. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UByte.toString(radix: Int): String ``` Returns a string representation of this [Byte](../kotlin/-byte/index#kotlin.Byte) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.UByte,%20kotlin.Int)/radix). Exceptions ---------- `IllegalArgumentException` - when [radix](to-string#kotlin.text%24toString(kotlin.UByte,%20kotlin.Int)/radix) is not a valid radix for number to string conversion. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UShort.toString(radix: Int): String ``` Returns a string representation of this [Short](../kotlin/-short/index#kotlin.Short) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.UShort,%20kotlin.Int)/radix). Exceptions ---------- `IllegalArgumentException` - when [radix](to-string#kotlin.text%24toString(kotlin.UShort,%20kotlin.Int)/radix) is not a valid radix for number to string conversion. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.toString(radix: Int): String ``` Returns a string representation of this [Int](../kotlin/-int/index#kotlin.Int) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.UInt,%20kotlin.Int)/radix). Exceptions ---------- `IllegalArgumentException` - when [radix](to-string#kotlin.text%24toString(kotlin.UInt,%20kotlin.Int)/radix) is not a valid radix for number to string conversion. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULong.toString(radix: Int): String ``` Returns a string representation of this [Long](../kotlin/-long/index#kotlin.Long) value in the specified [radix](to-string#kotlin.text%24toString(kotlin.ULong,%20kotlin.Int)/radix). Exceptions ---------- `IllegalArgumentException` - when [radix](to-string#kotlin.text%24toString(kotlin.ULong,%20kotlin.Int)/radix) is not a valid radix for number to string conversion. kotlin padEnd padEnd ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [padEnd](pad-end) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.padEnd(     length: Int,     padChar: Char = ' ' ): CharSequence ``` Returns a char sequence with content of this char sequence padded at the end to the specified [length](pad-end#kotlin.text%24padEnd(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/length) with the specified character or space. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val padWithSpace = "125".padEnd(5) println("'$padWithSpace'") // '125 ' val padWithChar = "a".padEnd(5, '.') println("'$padWithChar'") // 'a....' // string is returned as is, when its length is greater than the specified val noPadding = "abcde".padEnd(3) println("'$noPadding'") // 'abcde' //sampleEnd } ``` Parameters ---------- `length` - the desired string length. `padChar` - the character to pad string with, if it has length less than the [length](pad-end#kotlin.text%24padEnd(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/length) specified. Space is used by default. **Return** Returns a char sequence of length at least [length](pad-end#kotlin.text%24padEnd(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/length) consisting of `this` char sequence appended with [padChar](pad-end#kotlin.text%24padEnd(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Char)/padChar) as many times as are necessary to reach that length. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.padEnd(length: Int, padChar: Char = ' '): String ``` Pads the string to the specified [length](pad-end#kotlin.text%24padEnd(kotlin.String,%20kotlin.Int,%20kotlin.Char)/length) at the end with the specified character or space. ``` import java.util.Locale import kotlin.test.* fun main(args: Array<String>) { //sampleStart val padWithSpace = "125".padEnd(5) println("'$padWithSpace'") // '125 ' val padWithChar = "a".padEnd(5, '.') println("'$padWithChar'") // 'a....' // string is returned as is, when its length is greater than the specified val noPadding = "abcde".padEnd(3) println("'$noPadding'") // 'abcde' //sampleEnd } ``` Parameters ---------- `length` - the desired string length. `padChar` - the character to pad string with, if it has length less than the [length](pad-end#kotlin.text%24padEnd(kotlin.String,%20kotlin.Int,%20kotlin.Char)/length) specified. Space is used by default. **Return** Returns a string of length at least [length](pad-end#kotlin.text%24padEnd(kotlin.String,%20kotlin.Int,%20kotlin.Char)/length) consisting of `this` string appended with [padChar](pad-end#kotlin.text%24padEnd(kotlin.String,%20kotlin.Int,%20kotlin.Char)/padChar) as many times as are necessary to reach that length. kotlin max max === [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <max> **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("maxOrThrow") fun CharSequence.max(): Char ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun CharSequence.max(): Char? ``` **Deprecated:** Use maxOrNull instead. Returns the largest character. Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. kotlin lastIndex lastIndex ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [lastIndex](last-index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val CharSequence.lastIndex: Int ``` Returns the index of the last character in the char sequence or -1 if it is empty. kotlin isTitleCase isTitleCase =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isTitleCase](is-title-case) **Platform and version requirements:** JVM (1.0), JS (1.5) ``` fun Char.isTitleCase(): Boolean ``` Returns `true` if this character is a title case letter. A character is considered to be a title case letter if its category is [CharCategory.TITLECASE\_LETTER](-char-category/-t-i-t-l-e-c-a-s-e_-l-e-t-t-e-r#kotlin.text.CharCategory.TITLECASE_LETTER). ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('Dž', 'Lj', 'Nj', 'Dz', '1', 'A', 'a', '+') val (titleCases, notTitleCases) = chars.partition { it.isTitleCase() } println(titleCases) // [Dž, Lj, Nj, Dz] println(notTitleCases) // [1, A, a, +] //sampleEnd } ``` kotlin toUInt toUInt ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toUInt](to-u-int) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun String.toUInt(): UInt ``` Parses the string as an [UInt](../kotlin/-u-int/index) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun String.toUInt(radix: Int): UInt ``` Parses the string as an [UInt](../kotlin/-u-int/index) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. `IllegalArgumentException` - when [radix](to-u-int#kotlin.text%24toUInt(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion.
programming_docs
kotlin match match ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <match> **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.6") fun String.match(     regex: String ): Array<String>? ``` **Deprecated:** Use Regex.findAll() instead or invoke matches() on String dynamically: this.asDynamic().match(regex) kotlin indexOfFirst indexOfFirst ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [indexOfFirst](index-of-first) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.indexOfFirst(     predicate: (Char) -> Boolean ): Int ``` Returns index of the first character matching the given [predicate](index-of-first#kotlin.text%24indexOfFirst(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or -1 if the char sequence does not contain such character. kotlin groupingBy groupingBy ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [groupingBy](grouping-by) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <K> CharSequence.groupingBy(     crossinline keySelector: (Char) -> K ): Grouping<Char, K> ``` Creates a [Grouping](../kotlin.collections/-grouping/index) source from a char sequence to be used later with one of group-and-fold operations using the specified [keySelector](grouping-by#kotlin.text%24groupingBy(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.text.groupingBy.K)))/keySelector) function to extract a key from each character. ``` fun main(args: Array<String>) { //sampleStart val words = "one two three four five six seven eight nine ten".split(' ') val frequenciesByFirstChar = words.groupingBy { it.first() }.eachCount() println("Counting first letters:") println(frequenciesByFirstChar) // {o=1, t=3, f=2, s=2, e=1, n=1} val moreWords = "eleven twelve".split(' ') val moreFrequencies = moreWords.groupingBy { it.first() }.eachCountTo(frequenciesByFirstChar.toMutableMap()) println(moreFrequencies) // {o=1, t=4, f=2, s=2, e=2, n=1} //sampleEnd } ``` kotlin toBigInteger toBigInteger ============ [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toBigInteger](to-big-integer) **Platform and version requirements:** JVM (1.2) ``` fun String.toBigInteger(): BigInteger ``` Parses the string as a [java.math.BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. **Platform and version requirements:** JVM (1.2) ``` fun String.toBigInteger(radix: Int): BigInteger ``` Parses the string as a [java.math.BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number and returns the result. Exceptions ---------- `NumberFormatException` - if the string is not a valid representation of a number. `IllegalArgumentException` - when [radix](to-big-integer#kotlin.text%24toBigInteger(kotlin.String,%20kotlin.Int)/radix) is not a valid radix for string to number conversion. kotlin isJavaIdentifierPart isJavaIdentifierPart ==================== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isJavaIdentifierPart](is-java-identifier-part) **Platform and version requirements:** JVM (1.0) ``` fun Char.isJavaIdentifierPart(): Boolean ``` Returns `true` if this character (Unicode code point) may be part of a Java identifier as other than the first character. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('a', '_', '1', 'β', '$', '+', ';') val (javaIdentifierParts, notJavaIdentifierParts) = chars.partition { it.isJavaIdentifierPart() } println(javaIdentifierParts) // [a, _, 1, β, $] println(notJavaIdentifierParts) // [+, ;] //sampleEnd } ``` kotlin flatMapTo flatMapTo ========= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [flatMapTo](flat-map-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R, C : MutableCollection<in R>> CharSequence.flatMapTo(     destination: C,     transform: (Char) -> Iterable<R> ): C ``` Appends all elements yielded from results of [transform](flat-map-to#kotlin.text%24flatMapTo(kotlin.CharSequence,%20kotlin.text.flatMapTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMapTo.R)))))/transform) function being invoked on each character of original char sequence, to the given [destination](flat-map-to#kotlin.text%24flatMapTo(kotlin.CharSequence,%20kotlin.text.flatMapTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.Iterable((kotlin.text.flatMapTo.R)))))/destination). kotlin isLowSurrogate isLowSurrogate ============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isLowSurrogate](is-low-surrogate) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun Char.isLowSurrogate(): Boolean ``` Returns `true` if this character is a Unicode low-surrogate code unit (also known as trailing-surrogate code unit). kotlin toSet toSet ===== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [toSet](to-set) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.toSet(): Set<Char> ``` Returns a [Set](../kotlin.collections/-set/index#kotlin.collections.Set) of all characters. The returned set preserves the element iteration order of the original char sequence. kotlin buildString buildString =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [buildString](build-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun buildString(     builderAction: StringBuilder.() -> Unit ): String ``` Builds new string by populating newly created [StringBuilder](-string-builder/index#kotlin.text.StringBuilder) using provided [builderAction](build-string#kotlin.text%24buildString(kotlin.Function1((kotlin.text.StringBuilder,%20kotlin.Unit)))/builderAction) and then converting it to [String](../kotlin/-string/index#kotlin.String). **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun buildString(     capacity: Int,     builderAction: StringBuilder.() -> Unit ): String ``` Builds new string by populating newly created [StringBuilder](-string-builder/index#kotlin.text.StringBuilder) initialized with the given [capacity](build-string#kotlin.text%24buildString(kotlin.Int,%20kotlin.Function1((kotlin.text.StringBuilder,%20kotlin.Unit)))/capacity) using provided [builderAction](build-string#kotlin.text%24buildString(kotlin.Int,%20kotlin.Function1((kotlin.text.StringBuilder,%20kotlin.Unit)))/builderAction) and then converting it to [String](../kotlin/-string/index#kotlin.String). kotlin trimEnd trimEnd ======= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [trimEnd](trim-end) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun CharSequence.trimEnd(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a sub sequence of this char sequence having trailing characters matching the [predicate](trim-end#kotlin.text%24trimEnd(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun String.trimEnd(     predicate: (Char) -> Boolean ): String ``` Returns a string having trailing characters matching the [predicate](trim-end#kotlin.text%24trimEnd(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.trimEnd(vararg chars: Char): CharSequence ``` Returns a sub sequence of this char sequence having trailing characters from the [chars](trim-end#kotlin.text%24trimEnd(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.trimEnd(vararg chars: Char): String ``` Returns a string having trailing characters from the [chars](trim-end#kotlin.text%24trimEnd(kotlin.String,%20kotlin.CharArray)/chars) array removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun CharSequence.trimEnd(): CharSequence ``` Returns a sub sequence of this char sequence having trailing whitespace removed. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun String.trimEnd(): String ``` Returns a string having trailing whitespace removed. kotlin minByOrNull minByOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [minByOrNull](min-by-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` inline fun <R : Comparable<R>> CharSequence.minByOrNull(     selector: (Char) -> R ): Char? ``` Returns the first character yielding the smallest value of the given function or `null` if there are no characters. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("abcd", "abc", "ab", "abcde") val shortestString = list.minByOrNull { it.length } println(shortestString) // ab val emptyList = emptyList<String>() val emptyMin = emptyList.minByOrNull { it.length } println(emptyMin) // null //sampleEnd } ``` kotlin minWithOrNull minWithOrNull ============= [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [minWithOrNull](min-with-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun CharSequence.minWithOrNull(     comparator: Comparator<in Char> ): Char? ``` Returns the first character having the smallest value according to the provided [comparator](min-with-or-null#kotlin.text%24minWithOrNull(kotlin.CharSequence,%20kotlin.Comparator((kotlin.Char)))/comparator) or `null` if there are no characters. kotlin isLetterOrDigit isLetterOrDigit =============== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isLetterOrDigit](is-letter-or-digit) **Platform and version requirements:** JVM (1.0), JS (1.5) ``` fun Char.isLetterOrDigit(): Boolean ``` Returns `true` if this character is a letter or digit. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('a', '1', '+') val (letterOrDigitList, notLetterOrDigitList) = chars.partition { it.isLetterOrDigit() } println(letterOrDigitList) // [a, 1] println(notLetterOrDigitList) // [+] //sampleEnd } ``` **See Also** [isLetter](is-letter#kotlin.text%24isLetter(kotlin.Char)) [isDigit](is-digit#kotlin.text%24isDigit(kotlin.Char)) kotlin min min === [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / <min> **Platform and version requirements:** JS (1.7), Native (1.7) ``` @JvmName("minOrThrow") fun CharSequence.min(): Char ``` **Platform and version requirements:** JVM (1.0) ``` @DeprecatedSinceKotlin("1.4", "1.5", "1.6") fun CharSequence.min(): Char? ``` **Deprecated:** Use minOrNull instead. Returns the smallest character. Exceptions ---------- `NoSuchElementException` - if the char sequence is empty. kotlin deleteRange deleteRange =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [deleteRange](delete-range) **Platform and version requirements:** JS (1.4) ``` fun StringBuilder.deleteRange(     startIndex: Int,     endIndex: Int ): StringBuilder ``` Removes characters in the specified range from this string builder and returns this instance. Parameters ---------- `startIndex` - the beginning (inclusive) of the range to remove. `endIndex` - the end (exclusive) of the range to remove. Exceptions ---------- `IndexOutOfBoundsException` - or [IllegalArgumentException](../kotlin/-illegal-argument-exception/index#kotlin.IllegalArgumentException) when [startIndex](delete-range#kotlin.text%24deleteRange(kotlin.text.StringBuilder,%20kotlin.Int,%20kotlin.Int)/startIndex) is out of range of this string builder indices or when `startIndex > endIndex`. kotlin String String ====== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [String](-string) **Platform and version requirements:** JS (1.2), Native (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5") fun String(     chars: CharArray ): String ``` **Deprecated:** Use CharArray.concatToString() instead **Platform and version requirements:** JVM (1.0) ``` fun String(chars: CharArray): String ``` Converts the characters in the specified array to a string. **Platform and version requirements:** JS (1.2), Native (1.3) ``` @DeprecatedSinceKotlin("1.4", "1.5") fun String(     chars: CharArray,     offset: Int,     length: Int ): String ``` **Deprecated:** Use CharArray.concatToString(startIndex, endIndex) instead **Platform and version requirements:** JVM (1.0) ``` fun String(     chars: CharArray,     offset: Int,     length: Int ): String ``` Converts the characters from a portion of the specified array to a string. Exceptions ---------- `IndexOutOfBoundsException` - if either [offset](-string#kotlin.text%24String(kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/offset) or [length](-string#kotlin.text%24String(kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/length) are less than zero or `offset + length` is out of [chars](-string#kotlin.text%24String(kotlin.CharArray,%20kotlin.Int,%20kotlin.Int)/chars) array bounds. **Platform and version requirements:** JVM (1.0) ``` fun String(     bytes: ByteArray,     offset: Int,     length: Int,     charset: Charset ): String ``` Converts the data from a portion of the specified array of bytes to characters using the specified character set and returns the conversion result as a string. Parameters ---------- `bytes` - the source array for the conversion. `offset` - the offset in the array of the data to be converted. `length` - the number of bytes to be converted. `charset` - the character set to use. **Platform and version requirements:** JVM (1.0) ``` fun String(bytes: ByteArray, charset: Charset): String ``` Converts the data from the specified array of bytes to characters using the specified character set and returns the conversion result as a string. **Platform and version requirements:** JVM (1.0) ``` fun String(     bytes: ByteArray,     offset: Int,     length: Int ): String ``` Converts the data from a portion of the specified array of bytes to characters using the UTF-8 character set and returns the conversion result as a string. Parameters ---------- `bytes` - the source array for the conversion. `offset` - the offset in the array of the data to be converted. `length` - the number of bytes to be converted. **Platform and version requirements:** JVM (1.0) ``` fun String(bytes: ByteArray): String ``` Converts the data from the specified array of bytes to characters using the UTF-8 character set and returns the conversion result as a string. **Platform and version requirements:** JVM (1.0) ``` fun String(     codePoints: IntArray,     offset: Int,     length: Int ): String ``` Converts the code points from a portion of the specified Unicode code point array to a string. **Platform and version requirements:** JVM (1.0) ``` fun String(stringBuffer: StringBuffer): String ``` Converts the contents of the specified StringBuffer to a string. **Platform and version requirements:** JVM (1.0) ``` fun String(stringBuilder: StringBuilder): String ``` Converts the contents of the specified StringBuilder to a string. kotlin digitToInt digitToInt ========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [digitToInt](digit-to-int) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Char.digitToInt(): Int ``` Returns the numeric value of the decimal digit that this Char represents. Throws an exception if this Char is not a valid decimal digit. A Char is considered to represent a decimal digit if [isDigit](is-digit#kotlin.text%24isDigit(kotlin.Char)) is true for the Char. In this case, the Unicode decimal digit value of the character is returned. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart println('5'.digitToInt()) // 5 println('3'.digitToInt(radix = 8)) // 3 println('A'.digitToInt(radix = 16)) // 10 println('k'.digitToInt(radix = 36)) // 20 // radix argument should be in 2..36 // '0'.digitToInt(radix = 1) // will fail // '1'.digitToInt(radix = 100) // will fail // only 0 and 1 digits are valid for binary numbers // '5'.digitToInt(radix = 2) // will fail // radix = 10 is used by default // 'A'.digitToInt() // will fail // symbol '+' is not a digit in any radix // '+'.digitToInt() // will fail // Only Latin letters are valid for digits greater than 9. // 'β'.digitToInt(radix = 36) // will fail //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Char.digitToInt(radix: Int): Int ``` Returns the numeric value of the digit that this Char represents in the specified [radix](digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix). Throws an exception if the [radix](digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix) is not in the range `2..36` or if this Char is not a valid digit in the specified [radix](digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix). A Char is considered to represent a digit in the specified [radix](digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix) if at least one of the following is true: * [isDigit](is-digit#kotlin.text%24isDigit(kotlin.Char)) is `true` for the Char and the Unicode decimal digit value of the character is less than the specified [radix](digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix). In this case the decimal digit value is returned. * The Char is one of the uppercase Latin letters 'A' through 'Z' and its [code](../kotlin/code) is less than `radix + 'A'.code - 10`. In this case, `this.code - 'A'.code + 10` is returned. * The Char is one of the lowercase Latin letters 'a' through 'z' and its [code](../kotlin/code) is less than `radix + 'a'.code - 10`. In this case, `this.code - 'a'.code + 10` is returned. * The Char is one of the fullwidth Latin capital letters '\uFF21' through '\uFF3A' and its [code](../kotlin/code) is less than `radix + 0xFF21 - 10`. In this case, `this.code - 0xFF21 + 10` is returned. * The Char is one of the fullwidth Latin small letters '\uFF41' through '\uFF5A' and its [code](../kotlin/code) is less than `radix + 0xFF41 - 10`. In this case, `this.code - 0xFF41 + 10` is returned. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart println('5'.digitToInt()) // 5 println('3'.digitToInt(radix = 8)) // 3 println('A'.digitToInt(radix = 16)) // 10 println('k'.digitToInt(radix = 36)) // 20 // radix argument should be in 2..36 // '0'.digitToInt(radix = 1) // will fail // '1'.digitToInt(radix = 100) // will fail // only 0 and 1 digits are valid for binary numbers // '5'.digitToInt(radix = 2) // will fail // radix = 10 is used by default // 'A'.digitToInt() // will fail // symbol '+' is not a digit in any radix // '+'.digitToInt() // will fail // Only Latin letters are valid for digits greater than 9. // 'β'.digitToInt(radix = 36) // will fail //sampleEnd } ``` kotlin isLowerCase isLowerCase =========== [kotlin-stdlib](../../../../../index) / [kotlin.text](index) / [isLowerCase](is-lower-case) **Platform and version requirements:** JVM (1.0), JS (1.5) ``` fun Char.isLowerCase(): Boolean ``` Returns `true` if this character is lower case. A character is considered to be a lower case character if its category is [CharCategory.LOWERCASE\_LETTER](-char-category/-l-o-w-e-r-c-a-s-e_-l-e-t-t-e-r#kotlin.text.CharCategory.LOWERCASE_LETTER), or it has contributory property `Other_Lowercase` as defined by the Unicode Standard. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val chars = listOf('a', 'λ', 'A', '1', '+') val (lowerCases, notLowerCases) = chars.partition { it.isLowerCase() } println(lowerCases) // [a, λ] println(notLowerCases) // [A, 1, +] //sampleEnd } ```
programming_docs